| | | 1 | | // Copyright (c) 2020-2023 dotBunny Inc. |
| | | 2 | | // dotBunny licenses this file to you under the BSL-1.0 license. |
| | | 3 | | // See the LICENSE file in the project root for more information. |
| | | 4 | | |
| | | 5 | | using System; |
| | | 6 | | using GDX.Collections; |
| | | 7 | | using UnityEngine; |
| | | 8 | | |
| | | 9 | | namespace GDX.Tables |
| | | 10 | | { |
| | | 11 | | |
| | | 12 | | [CreateAssetMenu(menuName = "GDX/Stable Table", fileName = "GDXStableTable")] |
| | | 13 | | [Serializable] |
| | | 14 | | public class StableTable : ScriptableObject, ITable |
| | | 15 | | { |
| | | 16 | | |
| | | 17 | | [Serializable] |
| | | 18 | | internal struct ColumnEntry |
| | | 19 | | { |
| | | 20 | | public Serializable.SerializableTypes ColumnType; |
| | | 21 | | public int columnDenseIndex; |
| | | 22 | | } |
| | | 23 | | |
| | 0 | 24 | | [SerializeField] internal string m_DisplayName = "GDXStableTable"; |
| | | 25 | | |
| | | 26 | | [SerializeField] internal ArrayHolder<string>[] allStringColumns; |
| | | 27 | | [SerializeField] internal ArrayHolder<bool>[] allBoolColumns; |
| | | 28 | | [SerializeField] internal ArrayHolder<char>[] allCharColumns; |
| | | 29 | | [SerializeField] internal ArrayHolder<sbyte>[] allSbyteColumns; |
| | | 30 | | [SerializeField] internal ArrayHolder<byte>[] allByteColumns; |
| | | 31 | | [SerializeField] internal ArrayHolder<short>[] allShortColumns; |
| | | 32 | | [SerializeField] internal ArrayHolder<ushort>[] allUshortColumns; |
| | | 33 | | [SerializeField] internal ArrayHolder<int>[] allIntColumns; |
| | | 34 | | [SerializeField] internal ArrayHolder<uint>[] allUintColumns; |
| | | 35 | | [SerializeField] internal ArrayHolder<long>[] allLongColumns; |
| | | 36 | | [SerializeField] internal ArrayHolder<ulong>[] allUlongColumns; |
| | | 37 | | [SerializeField] internal ArrayHolder<float>[] allFloatColumns; |
| | | 38 | | [SerializeField] internal ArrayHolder<double>[] allDoubleColumns; |
| | | 39 | | [SerializeField] internal ArrayHolder<Vector2>[] allVector2Columns; |
| | | 40 | | [SerializeField] internal ArrayHolder<Vector3>[] allVector3Columns; |
| | | 41 | | [SerializeField] internal ArrayHolder<Vector4>[] allVector4Columns; |
| | | 42 | | [SerializeField] internal ArrayHolder<Vector2Int>[] allVector2IntColumns; |
| | | 43 | | [SerializeField] internal ArrayHolder<Vector3Int>[] allVector3IntColumns; |
| | | 44 | | [SerializeField] internal ArrayHolder<Quaternion>[] allQuaternionColumns; |
| | | 45 | | [SerializeField] internal ArrayHolder<Rect>[] allRectColumns; |
| | | 46 | | [SerializeField] internal ArrayHolder<RectInt>[] allRectIntColumns; |
| | | 47 | | [SerializeField] internal ArrayHolder<Color>[] allColorColumns; |
| | | 48 | | [SerializeField] internal ArrayHolder<LayerMask>[] allLayerMaskColumns; |
| | | 49 | | [SerializeField] internal ArrayHolder<Bounds>[] allBoundsColumns; |
| | | 50 | | [SerializeField] internal ArrayHolder<BoundsInt>[] allBoundsIntColumns; |
| | | 51 | | [SerializeField] internal ArrayHolder<Hash128>[] allHash128Columns; |
| | | 52 | | [SerializeField] internal ArrayHolder<Gradient>[] allGradientColumns; |
| | | 53 | | [SerializeField] internal ArrayHolder<AnimationCurve>[] allAnimationCurveColumns; |
| | | 54 | | [SerializeField] internal ArrayHolder<UnityEngine.Object>[] allObjectRefColumns; |
| | 0 | 55 | | [SerializeField] internal ArrayHolder<string>[] allColumnNames = new ArrayHolder<string>[Serializable.Serializab |
| | | 56 | | |
| | | 57 | | [SerializeField] internal int[] rowIDToDenseIndexMap; |
| | | 58 | | [SerializeField] internal int[] rowDenseIndexToIDMap; |
| | | 59 | | [SerializeField] internal string[] rowNames; |
| | | 60 | | [SerializeField] internal int rowEntriesFreeListHead; |
| | | 61 | | |
| | | 62 | | [SerializeField] |
| | | 63 | | internal int rowCount; |
| | | 64 | | |
| | | 65 | | [SerializeField] internal ColumnEntry[] columnIDToDenseIndexMap; |
| | | 66 | | [SerializeField] internal int[] columnIDToSortOrderMap; |
| | | 67 | | [SerializeField] internal int[] sortedOrderToColumnIDMap; |
| | | 68 | | |
| | | 69 | | // TODO move with other block |
| | 0 | 70 | | [SerializeField] ArrayHolder<int>[] columnDenseIndexToIDMap = new ArrayHolder<int>[Serializable.SerializableType |
| | | 71 | | |
| | | 72 | | [SerializeField] |
| | | 73 | | internal int columnEntriesFreeListHead; |
| | | 74 | | |
| | | 75 | | [SerializeField] |
| | | 76 | | internal int combinedColumnCount; |
| | | 77 | | |
| | | 78 | | [SerializeField] |
| | 0 | 79 | | internal ulong dataVersion = 1; |
| | | 80 | | |
| | | 81 | | [SerializeField] BitArray8 m_Flags; |
| | | 82 | | |
| | | 83 | | public ulong GetDataVersion() |
| | 0 | 84 | | { |
| | 0 | 85 | | return dataVersion; |
| | 0 | 86 | | } |
| | | 87 | | |
| | | 88 | | /// <inheritdoc /> |
| | | 89 | | public int GetColumnCount() |
| | 0 | 90 | | { |
| | 0 | 91 | | return combinedColumnCount; |
| | 0 | 92 | | } |
| | | 93 | | |
| | | 94 | | /// <inheritdoc /> |
| | | 95 | | public int GetRowCount() |
| | 0 | 96 | | { |
| | 0 | 97 | | return rowCount; |
| | 0 | 98 | | } |
| | | 99 | | |
| | | 100 | | public string GetDisplayName() |
| | 0 | 101 | | { |
| | 0 | 102 | | return m_DisplayName; |
| | 0 | 103 | | } |
| | | 104 | | |
| | | 105 | | public void SetDisplayName(string displayName) |
| | 0 | 106 | | { |
| | 0 | 107 | | m_DisplayName = displayName; |
| | 0 | 108 | | } |
| | | 109 | | |
| | | 110 | | public bool GetFlag(byte index) |
| | 0 | 111 | | { |
| | 0 | 112 | | return m_Flags[index]; |
| | 0 | 113 | | } |
| | | 114 | | |
| | | 115 | | public void SetFlag(byte index, bool toggle) |
| | 0 | 116 | | { |
| | 0 | 117 | | m_Flags[index] = toggle; |
| | 0 | 118 | | } |
| | | 119 | | |
| | | 120 | | public ITable.RowDescription[] GetAllRowDescriptions() |
| | 0 | 121 | | { |
| | 0 | 122 | | if (combinedColumnCount == 0 || rowCount == 0) return null; |
| | 0 | 123 | | ITable.RowDescription[] returnArray = new ITable.RowDescription[rowCount]; |
| | 0 | 124 | | string empty = string.Empty; |
| | 0 | 125 | | for (int i = 0; i < rowCount; i++) |
| | 0 | 126 | | { |
| | 0 | 127 | | returnArray[i].InternalIndex = rowDenseIndexToIDMap[i]; |
| | 0 | 128 | | returnArray[i].Name = rowNames[i]; |
| | 0 | 129 | | } |
| | | 130 | | |
| | 0 | 131 | | return returnArray; |
| | 0 | 132 | | } |
| | | 133 | | public ITable.RowDescription GetRowDescription(string name) |
| | 0 | 134 | | { |
| | 0 | 135 | | for (int i = 0; i < rowCount; i++) |
| | 0 | 136 | | { |
| | 0 | 137 | | string nameAt = rowNames[i]; |
| | | 138 | | |
| | 0 | 139 | | if (nameAt == name) |
| | 0 | 140 | | { |
| | 0 | 141 | | return new ITable.RowDescription |
| | | 142 | | { |
| | | 143 | | InternalIndex = rowDenseIndexToIDMap[i], |
| | | 144 | | Name = nameAt, |
| | | 145 | | }; |
| | | 146 | | } |
| | 0 | 147 | | } |
| | | 148 | | |
| | 0 | 149 | | throw new ArgumentException("Row with name " + name + " does not exist in the table"); |
| | 0 | 150 | | } |
| | | 151 | | |
| | | 152 | | public ITable.RowDescription GetRowDescription(int order) |
| | 0 | 153 | | { |
| | 0 | 154 | | return new ITable.RowDescription |
| | | 155 | | { |
| | | 156 | | InternalIndex = rowDenseIndexToIDMap[order], |
| | | 157 | | Name = rowNames[order], |
| | | 158 | | }; |
| | 0 | 159 | | } |
| | | 160 | | |
| | | 161 | | public void SetAllRowDescriptionsOrder(ITable.RowDescription[] orderedRows) |
| | 0 | 162 | | { |
| | | 163 | | // TODO: @adam array coming in be in the new order, just use the internalIndex (stable to reorder inside her |
| | 0 | 164 | | throw new NotImplementedException(); |
| | | 165 | | } |
| | | 166 | | |
| | | 167 | | public ITable.ColumnDescription GetColumnDescription(string name) |
| | 0 | 168 | | { |
| | 0 | 169 | | for (int i = 0; i < Serializable.SerializableTypesCount; i++) |
| | 0 | 170 | | { |
| | 0 | 171 | | string[] columnNames = allColumnNames[i].TArray; |
| | | 172 | | |
| | 0 | 173 | | if (columnNames != null) |
| | 0 | 174 | | { |
| | 0 | 175 | | for (int j = 0; j < columnNames.Length; j++) |
| | 0 | 176 | | { |
| | 0 | 177 | | string nameAt = columnNames[j]; |
| | | 178 | | |
| | 0 | 179 | | if (name == nameAt) |
| | 0 | 180 | | { |
| | 0 | 181 | | int columnID = columnDenseIndexToIDMap[i].TArray[j]; |
| | | 182 | | |
| | 0 | 183 | | ref ColumnEntry columnEntry = ref columnIDToDenseIndexMap[columnID]; |
| | 0 | 184 | | return new ITable.ColumnDescription |
| | | 185 | | { |
| | | 186 | | InternalIndex = columnID, |
| | | 187 | | Name = nameAt, |
| | | 188 | | Type = columnEntry.ColumnType, |
| | | 189 | | }; |
| | | 190 | | } |
| | 0 | 191 | | } |
| | 0 | 192 | | } |
| | 0 | 193 | | } |
| | | 194 | | |
| | 0 | 195 | | throw new ArgumentException("Column with name " + name + " does not exist in the table"); |
| | 0 | 196 | | } |
| | | 197 | | |
| | | 198 | | public ITable.ColumnDescription GetColumnDescription(int order) |
| | 0 | 199 | | { |
| | 0 | 200 | | int idAtOrderedIndex = sortedOrderToColumnIDMap[order]; |
| | 0 | 201 | | ref ColumnEntry columnEntry = ref columnIDToDenseIndexMap[idAtOrderedIndex]; |
| | | 202 | | |
| | 0 | 203 | | string columnName = allColumnNames[(int)columnEntry.ColumnType][columnEntry.columnDenseIndex]; |
| | | 204 | | |
| | 0 | 205 | | return new ITable.ColumnDescription |
| | | 206 | | { |
| | | 207 | | InternalIndex = idAtOrderedIndex, |
| | | 208 | | Name = columnName, |
| | | 209 | | Type = columnEntry.ColumnType, |
| | | 210 | | }; |
| | 0 | 211 | | } |
| | | 212 | | |
| | | 213 | | public void SetAllColumnDescriptionsOrder(ITable.ColumnDescription[] orderedColumns) |
| | 0 | 214 | | { |
| | | 215 | | // TODO: @adam array coming in be in the new order, just use the internalIndex (stable to reorder inside her |
| | 0 | 216 | | throw new NotImplementedException(); |
| | | 217 | | } |
| | | 218 | | |
| | | 219 | | /// <inheritdoc /> |
| | | 220 | | public ITable.ColumnDescription[] GetAllColumnDescriptions() |
| | 0 | 221 | | { |
| | 0 | 222 | | if (combinedColumnCount == 0) return null; |
| | 0 | 223 | | ITable.ColumnDescription[] returnArray = new ITable.ColumnDescription[combinedColumnCount]; |
| | | 224 | | |
| | 0 | 225 | | for (int i = 0; i < combinedColumnCount; i++) |
| | 0 | 226 | | { |
| | 0 | 227 | | int columnID = sortedOrderToColumnIDMap[i]; |
| | 0 | 228 | | AssertColumnIDValid(columnID); |
| | 0 | 229 | | ref ColumnEntry entryForID = ref columnIDToDenseIndexMap[columnID]; |
| | 0 | 230 | | ref ArrayHolder<string> nameColumnsForType = ref allColumnNames[(int)entryForID.ColumnType]; |
| | | 231 | | |
| | 0 | 232 | | string name = nameColumnsForType[entryForID.columnDenseIndex]; |
| | | 233 | | |
| | 0 | 234 | | returnArray[i] = new ITable.ColumnDescription |
| | | 235 | | { |
| | | 236 | | Name = name, |
| | | 237 | | InternalIndex = columnID, |
| | | 238 | | Type = entryForID.ColumnType, |
| | | 239 | | }; |
| | 0 | 240 | | } |
| | | 241 | | |
| | 0 | 242 | | return returnArray; |
| | 0 | 243 | | } |
| | | 244 | | |
| | | 245 | | internal void AssertColumnIDValid(int columnID) |
| | 0 | 246 | | { |
| | 0 | 247 | | if (columnID < 0 || columnID >= columnIDToDenseIndexMap.Length) |
| | 0 | 248 | | { |
| | 0 | 249 | | throw new ArgumentException("Invalid column outside valid ID range: " + columnID); |
| | | 250 | | } |
| | | 251 | | |
| | 0 | 252 | | ref ColumnEntry columnEntry = ref columnIDToDenseIndexMap[columnID]; |
| | | 253 | | |
| | 0 | 254 | | if (columnEntry.ColumnType == Serializable.SerializableTypes.Invalid) |
| | 0 | 255 | | { |
| | 0 | 256 | | throw new ArgumentException("Invalid column pointing to deallocated entry: " + columnID); |
| | | 257 | | } |
| | 0 | 258 | | } |
| | | 259 | | |
| | | 260 | | internal void AssertRowIDValid(int rowID) |
| | 0 | 261 | | { |
| | 0 | 262 | | if (rowID < 0 || rowID >= rowIDToDenseIndexMap.Length) |
| | 0 | 263 | | { |
| | 0 | 264 | | throw new ArgumentException("Invalid row outside valid ID range: " + rowID); |
| | | 265 | | } |
| | | 266 | | |
| | 0 | 267 | | int rowIndex = rowIDToDenseIndexMap[rowID]; |
| | | 268 | | |
| | 0 | 269 | | if (rowIndex >= rowCount || rowIndex < 0) |
| | 0 | 270 | | { |
| | 0 | 271 | | throw new ArgumentException("Invalid row outside valid ID range: " + rowID); |
| | | 272 | | } |
| | 0 | 273 | | } |
| | | 274 | | |
| | | 275 | | public void SetColumnName(string columnName, int column) |
| | 0 | 276 | | { |
| | 0 | 277 | | AssertColumnIDValid(column); |
| | 0 | 278 | | ref ColumnEntry columnEntry = ref columnIDToDenseIndexMap[column]; |
| | 0 | 279 | | allColumnNames[(int)columnEntry.ColumnType][columnEntry.columnDenseIndex] = columnName; |
| | 0 | 280 | | } |
| | | 281 | | |
| | | 282 | | public string GetColumnName(int column) |
| | 0 | 283 | | { |
| | 0 | 284 | | AssertColumnIDValid(column); |
| | 0 | 285 | | ref ColumnEntry columnEntry = ref columnIDToDenseIndexMap[column]; |
| | 0 | 286 | | return allColumnNames[(int)columnEntry.ColumnType][columnEntry.columnDenseIndex]; |
| | 0 | 287 | | } |
| | | 288 | | |
| | | 289 | | public void SetRowName(string rowName, int row) |
| | 0 | 290 | | { |
| | 0 | 291 | | AssertRowIDValid(row); |
| | 0 | 292 | | int rowDenseIndex = rowIDToDenseIndexMap[row]; |
| | 0 | 293 | | rowNames[rowDenseIndex] = rowName; |
| | 0 | 294 | | } |
| | | 295 | | |
| | | 296 | | public string GetRowName(int row) |
| | 0 | 297 | | { |
| | 0 | 298 | | AssertRowIDValid(row); |
| | 0 | 299 | | int rowDenseIndex = rowIDToDenseIndexMap[row]; |
| | 0 | 300 | | return rowNames[rowDenseIndex]; |
| | 0 | 301 | | } |
| | | 302 | | |
| | | 303 | | public ref string GetRowNameRef(int row) |
| | 0 | 304 | | { |
| | 0 | 305 | | AssertRowIDValid(row); |
| | 0 | 306 | | int rowDenseIndex = rowIDToDenseIndexMap[row]; |
| | 0 | 307 | | return ref rowNames[rowDenseIndex]; |
| | 0 | 308 | | } |
| | | 309 | | |
| | | 310 | | public ref string GetColumnNameRef(int columnID) |
| | 0 | 311 | | { |
| | 0 | 312 | | AssertColumnIDValid(columnID); |
| | 0 | 313 | | ref ColumnEntry columnEntry = ref columnIDToDenseIndexMap[columnID]; |
| | 0 | 314 | | return ref allColumnNames[(int)columnEntry.ColumnType][columnEntry.columnDenseIndex]; |
| | 0 | 315 | | } |
| | | 316 | | |
| | | 317 | | |
| | | 318 | | public int AddRow(string rowName = null, int insertAtRowID = -1) |
| | 0 | 319 | | { |
| | 0 | 320 | | if (insertAtRowID >= 0) |
| | 0 | 321 | | { |
| | 0 | 322 | | AssertRowIDValid(insertAtRowID); |
| | 0 | 323 | | } |
| | 0 | 324 | | int rowID = rowEntriesFreeListHead; |
| | 0 | 325 | | int rowIDToDenseIndexMapLength = rowIDToDenseIndexMap?.Length ?? 0; |
| | 0 | 326 | | if (rowID >= rowIDToDenseIndexMapLength) |
| | 0 | 327 | | { |
| | 0 | 328 | | int newSize = rowID * 2; |
| | 0 | 329 | | newSize = newSize == 0 ? 1 : newSize; |
| | 0 | 330 | | Array.Resize(ref rowIDToDenseIndexMap, newSize); |
| | 0 | 331 | | for (int i = rowID; i < newSize; i++) |
| | 0 | 332 | | { |
| | 0 | 333 | | rowIDToDenseIndexMap[i] = i + 1; |
| | 0 | 334 | | } |
| | 0 | 335 | | } |
| | | 336 | | |
| | 0 | 337 | | int denseIndexToIDMapLength = rowDenseIndexToIDMap?.Length ?? 0; |
| | 0 | 338 | | Array.Resize(ref rowDenseIndexToIDMap, denseIndexToIDMapLength + 1); |
| | 0 | 339 | | Array.Resize(ref rowNames, denseIndexToIDMapLength + 1); |
| | | 340 | | |
| | 0 | 341 | | int insertAt = insertAtRowID < 0 ? rowCount : rowIDToDenseIndexMap[insertAtRowID]; |
| | | 342 | | |
| | 0 | 343 | | for (int i = denseIndexToIDMapLength; i > insertAt; i--) |
| | 0 | 344 | | { |
| | 0 | 345 | | int currentRowID = rowDenseIndexToIDMap[i - 1]; |
| | 0 | 346 | | rowDenseIndexToIDMap[i] = currentRowID; |
| | | 347 | | |
| | 0 | 348 | | rowIDToDenseIndexMap[currentRowID] = i; |
| | | 349 | | |
| | 0 | 350 | | rowNames[i] = rowNames[i - 1]; |
| | 0 | 351 | | } |
| | | 352 | | |
| | 0 | 353 | | rowEntriesFreeListHead = rowIDToDenseIndexMap[rowID]; |
| | 0 | 354 | | rowIDToDenseIndexMap[rowID] = insertAt; |
| | 0 | 355 | | rowDenseIndexToIDMap[insertAt] = rowID; |
| | 0 | 356 | | rowNames[insertAt] = rowName == null ? rowID.ToString() : rowName; |
| | | 357 | | |
| | 0 | 358 | | InsertRowsOfTypeInternal(ref allStringColumns, insertAt, 1); |
| | 0 | 359 | | InsertRowsOfTypeInternal(ref allBoolColumns, insertAt, 1); |
| | 0 | 360 | | InsertRowsOfTypeInternal(ref allCharColumns, insertAt, 1); |
| | 0 | 361 | | InsertRowsOfTypeInternal(ref allSbyteColumns, insertAt, 1); |
| | 0 | 362 | | InsertRowsOfTypeInternal(ref allByteColumns, insertAt, 1); |
| | 0 | 363 | | InsertRowsOfTypeInternal(ref allShortColumns, insertAt, 1); |
| | 0 | 364 | | InsertRowsOfTypeInternal(ref allUshortColumns, insertAt, 1); |
| | 0 | 365 | | InsertRowsOfTypeInternal(ref allIntColumns, insertAt, 1); |
| | 0 | 366 | | InsertRowsOfTypeInternal(ref allUintColumns, insertAt, 1); |
| | 0 | 367 | | InsertRowsOfTypeInternal(ref allLongColumns, insertAt, 1); |
| | 0 | 368 | | InsertRowsOfTypeInternal(ref allUlongColumns, insertAt, 1); |
| | 0 | 369 | | InsertRowsOfTypeInternal(ref allFloatColumns, insertAt, 1); |
| | 0 | 370 | | InsertRowsOfTypeInternal(ref allDoubleColumns, insertAt, 1); |
| | 0 | 371 | | InsertRowsOfTypeInternal(ref allVector2Columns, insertAt, 1); |
| | 0 | 372 | | InsertRowsOfTypeInternal(ref allVector3Columns, insertAt, 1); |
| | 0 | 373 | | InsertRowsOfTypeInternal(ref allVector4Columns, insertAt, 1); |
| | 0 | 374 | | InsertRowsOfTypeInternal(ref allVector2IntColumns, insertAt, 1); |
| | 0 | 375 | | InsertRowsOfTypeInternal(ref allVector3IntColumns, insertAt, 1); |
| | 0 | 376 | | InsertRowsOfTypeInternal(ref allQuaternionColumns, insertAt, 1); |
| | 0 | 377 | | InsertRowsOfTypeInternal(ref allRectColumns, insertAt, 1); |
| | 0 | 378 | | InsertRowsOfTypeInternal(ref allRectIntColumns, insertAt, 1); |
| | 0 | 379 | | InsertRowsOfTypeInternal(ref allColorColumns, insertAt, 1); |
| | 0 | 380 | | InsertRowsOfTypeInternal(ref allLayerMaskColumns, insertAt, 1); |
| | 0 | 381 | | InsertRowsOfTypeInternal(ref allBoundsColumns, insertAt, 1); |
| | 0 | 382 | | InsertRowsOfTypeInternal(ref allBoundsIntColumns, insertAt, 1); |
| | 0 | 383 | | InsertRowsOfTypeInternal(ref allHash128Columns, insertAt, 1); |
| | 0 | 384 | | InsertRowsOfTypeInternal(ref allGradientColumns, insertAt, 1); |
| | 0 | 385 | | InsertRowsOfTypeInternal(ref allAnimationCurveColumns, insertAt, 1); |
| | 0 | 386 | | InsertRowsOfTypeInternal(ref allObjectRefColumns, insertAt, 1); |
| | | 387 | | |
| | 0 | 388 | | ++rowCount; |
| | 0 | 389 | | dataVersion++; |
| | | 390 | | |
| | 0 | 391 | | return rowID; |
| | 0 | 392 | | } |
| | | 393 | | |
| | | 394 | | public void AddRows(int numberOfNewRows, string[] rowNames = null, int insertAtRowID = -1) |
| | 0 | 395 | | { |
| | 0 | 396 | | if (insertAtRowID >= 0) |
| | 0 | 397 | | { |
| | 0 | 398 | | AssertRowIDValid(insertAtRowID); |
| | 0 | 399 | | } |
| | 0 | 400 | | int rowIDToDenseIndexMapLength = rowIDToDenseIndexMap?.Length ?? 0; |
| | 0 | 401 | | int newCount = rowCount + numberOfNewRows; |
| | 0 | 402 | | if (newCount > rowIDToDenseIndexMapLength) |
| | 0 | 403 | | { |
| | 0 | 404 | | int newSize = newCount; |
| | 0 | 405 | | --newSize; |
| | 0 | 406 | | newSize |= newSize >> 1; |
| | 0 | 407 | | newSize |= newSize >> 2; |
| | 0 | 408 | | newSize |= newSize >> 4; |
| | 0 | 409 | | newSize |= newSize >> 8; |
| | 0 | 410 | | newSize |= newSize >> 16; |
| | 0 | 411 | | ++newSize; |
| | | 412 | | |
| | 0 | 413 | | newSize = newSize == 0 ? 1 : newSize; |
| | 0 | 414 | | Array.Resize(ref rowIDToDenseIndexMap, newSize); |
| | 0 | 415 | | for (int i = rowIDToDenseIndexMapLength; i < newSize; i++) |
| | 0 | 416 | | { |
| | 0 | 417 | | rowIDToDenseIndexMap[i] = i + 1; |
| | 0 | 418 | | } |
| | 0 | 419 | | } |
| | | 420 | | |
| | 0 | 421 | | int denseIndexToIDMapLength = rowDenseIndexToIDMap?.Length ?? 0; |
| | 0 | 422 | | Array.Resize(ref rowDenseIndexToIDMap, denseIndexToIDMapLength + numberOfNewRows); |
| | 0 | 423 | | Array.Resize(ref rowNames, denseIndexToIDMapLength + numberOfNewRows); |
| | | 424 | | |
| | 0 | 425 | | int insertAt = insertAtRowID < 0 ? rowCount : rowIDToDenseIndexMap[insertAtRowID]; |
| | | 426 | | |
| | 0 | 427 | | for (int i = denseIndexToIDMapLength; i > insertAt + numberOfNewRows - 1; i--) |
| | 0 | 428 | | { |
| | 0 | 429 | | int currentRowID = rowDenseIndexToIDMap[i - numberOfNewRows]; |
| | 0 | 430 | | rowDenseIndexToIDMap[i] = currentRowID; |
| | | 431 | | |
| | 0 | 432 | | rowIDToDenseIndexMap[currentRowID] = i; |
| | | 433 | | |
| | 0 | 434 | | rowNames[i] = rowNames[i - numberOfNewRows]; |
| | 0 | 435 | | } |
| | | 436 | | |
| | 0 | 437 | | int freeListHead = rowEntriesFreeListHead; |
| | | 438 | | |
| | 0 | 439 | | for (int i = 0; i < numberOfNewRows; i++) |
| | 0 | 440 | | { |
| | 0 | 441 | | int rowID = freeListHead; |
| | 0 | 442 | | freeListHead = rowIDToDenseIndexMap[rowID]; |
| | 0 | 443 | | rowIDToDenseIndexMap[rowID] = insertAt + i; |
| | 0 | 444 | | rowDenseIndexToIDMap[insertAt + i] = rowID; |
| | 0 | 445 | | } |
| | | 446 | | |
| | 0 | 447 | | int numberOfNewRowNames = rowNames?.Length ?? 0; |
| | 0 | 448 | | string emptyString = string.Empty; |
| | 0 | 449 | | for (int i = 0; i < numberOfNewRowNames; i++) |
| | 0 | 450 | | { |
| | 0 | 451 | | string currentRowName = rowNames[i]; |
| | 0 | 452 | | int rowIDAt = rowDenseIndexToIDMap[insertAt + i]; |
| | 0 | 453 | | rowNames[insertAt + i] = currentRowName == null ? rowIDAt.ToString() : currentRowName; |
| | 0 | 454 | | } |
| | | 455 | | |
| | 0 | 456 | | for (int i = numberOfNewRowNames; i < numberOfNewRows; i++) |
| | 0 | 457 | | { |
| | 0 | 458 | | int rowIDAt = rowDenseIndexToIDMap[insertAt + i]; |
| | 0 | 459 | | rowNames[insertAt + i] = rowIDAt.ToString(); |
| | 0 | 460 | | } |
| | | 461 | | |
| | 0 | 462 | | rowEntriesFreeListHead = freeListHead; |
| | | 463 | | |
| | 0 | 464 | | InsertRowsOfTypeInternal(ref allStringColumns, insertAt, numberOfNewRows); |
| | 0 | 465 | | InsertRowsOfTypeInternal(ref allBoolColumns, insertAt, numberOfNewRows); |
| | 0 | 466 | | InsertRowsOfTypeInternal(ref allCharColumns, insertAt, numberOfNewRows); |
| | 0 | 467 | | InsertRowsOfTypeInternal(ref allSbyteColumns, insertAt, numberOfNewRows); |
| | 0 | 468 | | InsertRowsOfTypeInternal(ref allByteColumns, insertAt, numberOfNewRows); |
| | 0 | 469 | | InsertRowsOfTypeInternal(ref allShortColumns, insertAt, numberOfNewRows); |
| | 0 | 470 | | InsertRowsOfTypeInternal(ref allUshortColumns, insertAt, numberOfNewRows); |
| | 0 | 471 | | InsertRowsOfTypeInternal(ref allIntColumns, insertAt, numberOfNewRows); |
| | 0 | 472 | | InsertRowsOfTypeInternal(ref allUintColumns, insertAt, numberOfNewRows); |
| | 0 | 473 | | InsertRowsOfTypeInternal(ref allLongColumns, insertAt, numberOfNewRows); |
| | 0 | 474 | | InsertRowsOfTypeInternal(ref allUlongColumns, insertAt, numberOfNewRows); |
| | 0 | 475 | | InsertRowsOfTypeInternal(ref allFloatColumns, insertAt, numberOfNewRows); |
| | 0 | 476 | | InsertRowsOfTypeInternal(ref allDoubleColumns, insertAt, numberOfNewRows); |
| | 0 | 477 | | InsertRowsOfTypeInternal(ref allVector2Columns, insertAt, numberOfNewRows); |
| | 0 | 478 | | InsertRowsOfTypeInternal(ref allVector3Columns, insertAt, numberOfNewRows); |
| | 0 | 479 | | InsertRowsOfTypeInternal(ref allVector4Columns, insertAt, numberOfNewRows); |
| | 0 | 480 | | InsertRowsOfTypeInternal(ref allVector2IntColumns, insertAt, numberOfNewRows); |
| | 0 | 481 | | InsertRowsOfTypeInternal(ref allVector3IntColumns, insertAt, numberOfNewRows); |
| | 0 | 482 | | InsertRowsOfTypeInternal(ref allQuaternionColumns, insertAt, numberOfNewRows); |
| | 0 | 483 | | InsertRowsOfTypeInternal(ref allRectColumns, insertAt, numberOfNewRows); |
| | 0 | 484 | | InsertRowsOfTypeInternal(ref allRectIntColumns, insertAt, numberOfNewRows); |
| | 0 | 485 | | InsertRowsOfTypeInternal(ref allColorColumns, insertAt, numberOfNewRows); |
| | 0 | 486 | | InsertRowsOfTypeInternal(ref allLayerMaskColumns, insertAt, numberOfNewRows); |
| | 0 | 487 | | InsertRowsOfTypeInternal(ref allBoundsColumns, insertAt, numberOfNewRows); |
| | 0 | 488 | | InsertRowsOfTypeInternal(ref allBoundsIntColumns, insertAt, numberOfNewRows); |
| | 0 | 489 | | InsertRowsOfTypeInternal(ref allHash128Columns, insertAt, numberOfNewRows); |
| | 0 | 490 | | InsertRowsOfTypeInternal(ref allGradientColumns, insertAt, numberOfNewRows); |
| | 0 | 491 | | InsertRowsOfTypeInternal(ref allAnimationCurveColumns, insertAt, numberOfNewRows); |
| | 0 | 492 | | InsertRowsOfTypeInternal(ref allObjectRefColumns, insertAt, numberOfNewRows); |
| | | 493 | | |
| | 0 | 494 | | rowCount += numberOfNewRows; |
| | 0 | 495 | | dataVersion++; |
| | 0 | 496 | | } |
| | | 497 | | |
| | | 498 | | public void AddRows(int numberOfNewRows, ref int[] rowIDs, string[] rowNames = null, int insertAtRowID = -1) |
| | 0 | 499 | | { |
| | 0 | 500 | | if (insertAtRowID >= 0) |
| | 0 | 501 | | { |
| | 0 | 502 | | AssertRowIDValid(insertAtRowID); |
| | 0 | 503 | | } |
| | 0 | 504 | | int rowIDToDenseIndexMapLength = rowIDToDenseIndexMap?.Length ?? 0; |
| | 0 | 505 | | int newCount = rowCount + numberOfNewRows; |
| | 0 | 506 | | if (newCount > rowIDToDenseIndexMapLength) |
| | 0 | 507 | | { |
| | 0 | 508 | | int newSize = newCount; |
| | 0 | 509 | | --newSize; |
| | 0 | 510 | | newSize |= newSize >> 1; |
| | 0 | 511 | | newSize |= newSize >> 2; |
| | 0 | 512 | | newSize |= newSize >> 4; |
| | 0 | 513 | | newSize |= newSize >> 8; |
| | 0 | 514 | | newSize |= newSize >> 16; |
| | 0 | 515 | | ++newSize; |
| | | 516 | | |
| | 0 | 517 | | newSize = newSize == 0 ? 1 : newSize; |
| | 0 | 518 | | Array.Resize(ref rowIDToDenseIndexMap, newSize); |
| | 0 | 519 | | for (int i = rowIDToDenseIndexMapLength; i < newSize; i++) |
| | 0 | 520 | | { |
| | 0 | 521 | | rowIDToDenseIndexMap[i] = i + 1; |
| | 0 | 522 | | } |
| | 0 | 523 | | } |
| | | 524 | | |
| | 0 | 525 | | int denseIndexToIDMapLength = rowDenseIndexToIDMap?.Length ?? 0; |
| | 0 | 526 | | Array.Resize(ref rowDenseIndexToIDMap, denseIndexToIDMapLength + numberOfNewRows); |
| | | 527 | | |
| | 0 | 528 | | int insertAt = insertAtRowID < 0 ? rowCount : rowIDToDenseIndexMap[insertAtRowID]; |
| | | 529 | | |
| | 0 | 530 | | for (int i = denseIndexToIDMapLength; i > insertAt + numberOfNewRows - 1; i--) |
| | 0 | 531 | | { |
| | 0 | 532 | | int currentRowID = rowDenseIndexToIDMap[i - numberOfNewRows]; |
| | 0 | 533 | | rowDenseIndexToIDMap[i] = currentRowID; |
| | | 534 | | |
| | 0 | 535 | | rowIDToDenseIndexMap[currentRowID] = i; |
| | | 536 | | |
| | 0 | 537 | | rowNames[i] = rowNames[i - numberOfNewRows]; |
| | 0 | 538 | | } |
| | | 539 | | |
| | 0 | 540 | | int freeListHead = rowEntriesFreeListHead; |
| | | 541 | | |
| | 0 | 542 | | for (int i = 0; i < numberOfNewRows; i++) |
| | 0 | 543 | | { |
| | 0 | 544 | | int rowID = freeListHead; |
| | 0 | 545 | | freeListHead = rowIDToDenseIndexMap[rowID]; |
| | 0 | 546 | | rowIDToDenseIndexMap[rowID] = insertAt + i; |
| | 0 | 547 | | rowDenseIndexToIDMap[insertAt + i] = rowID; |
| | 0 | 548 | | rowIDs[i] = rowID; |
| | 0 | 549 | | } |
| | | 550 | | |
| | 0 | 551 | | int numberOfNewRowNames = rowNames?.Length ?? 0; |
| | 0 | 552 | | for (int i = 0; i < numberOfNewRowNames; i++) |
| | 0 | 553 | | { |
| | 0 | 554 | | string currentRowName = rowNames[i]; |
| | 0 | 555 | | int rowIDAt = rowDenseIndexToIDMap[insertAt + i]; |
| | 0 | 556 | | rowNames[insertAt + i] = currentRowName == null ? rowIDAt.ToString() : currentRowName; |
| | 0 | 557 | | } |
| | | 558 | | |
| | 0 | 559 | | for (int i = numberOfNewRowNames; i < numberOfNewRows; i++) |
| | 0 | 560 | | { |
| | 0 | 561 | | int rowIDAt = rowDenseIndexToIDMap[insertAt + i]; |
| | 0 | 562 | | rowNames[insertAt + i] = rowIDAt.ToString(); |
| | 0 | 563 | | } |
| | | 564 | | |
| | 0 | 565 | | rowEntriesFreeListHead = freeListHead; |
| | | 566 | | |
| | 0 | 567 | | InsertRowsOfTypeInternal(ref allStringColumns, insertAt, numberOfNewRows); |
| | 0 | 568 | | InsertRowsOfTypeInternal(ref allBoolColumns, insertAt, numberOfNewRows); |
| | 0 | 569 | | InsertRowsOfTypeInternal(ref allCharColumns, insertAt, numberOfNewRows); |
| | 0 | 570 | | InsertRowsOfTypeInternal(ref allSbyteColumns, insertAt, numberOfNewRows); |
| | 0 | 571 | | InsertRowsOfTypeInternal(ref allByteColumns, insertAt, numberOfNewRows); |
| | 0 | 572 | | InsertRowsOfTypeInternal(ref allShortColumns, insertAt, numberOfNewRows); |
| | 0 | 573 | | InsertRowsOfTypeInternal(ref allUshortColumns, insertAt, numberOfNewRows); |
| | 0 | 574 | | InsertRowsOfTypeInternal(ref allIntColumns, insertAt, numberOfNewRows); |
| | 0 | 575 | | InsertRowsOfTypeInternal(ref allUintColumns, insertAt, numberOfNewRows); |
| | 0 | 576 | | InsertRowsOfTypeInternal(ref allLongColumns, insertAt, numberOfNewRows); |
| | 0 | 577 | | InsertRowsOfTypeInternal(ref allUlongColumns, insertAt, numberOfNewRows); |
| | 0 | 578 | | InsertRowsOfTypeInternal(ref allFloatColumns, insertAt, numberOfNewRows); |
| | 0 | 579 | | InsertRowsOfTypeInternal(ref allDoubleColumns, insertAt, numberOfNewRows); |
| | 0 | 580 | | InsertRowsOfTypeInternal(ref allVector2Columns, insertAt, numberOfNewRows); |
| | 0 | 581 | | InsertRowsOfTypeInternal(ref allVector3Columns, insertAt, numberOfNewRows); |
| | 0 | 582 | | InsertRowsOfTypeInternal(ref allVector4Columns, insertAt, numberOfNewRows); |
| | 0 | 583 | | InsertRowsOfTypeInternal(ref allVector2IntColumns, insertAt, numberOfNewRows); |
| | 0 | 584 | | InsertRowsOfTypeInternal(ref allVector3IntColumns, insertAt, numberOfNewRows); |
| | 0 | 585 | | InsertRowsOfTypeInternal(ref allQuaternionColumns, insertAt, numberOfNewRows); |
| | 0 | 586 | | InsertRowsOfTypeInternal(ref allRectColumns, insertAt, numberOfNewRows); |
| | 0 | 587 | | InsertRowsOfTypeInternal(ref allRectIntColumns, insertAt, numberOfNewRows); |
| | 0 | 588 | | InsertRowsOfTypeInternal(ref allColorColumns, insertAt, numberOfNewRows); |
| | 0 | 589 | | InsertRowsOfTypeInternal(ref allLayerMaskColumns, insertAt, numberOfNewRows); |
| | 0 | 590 | | InsertRowsOfTypeInternal(ref allBoundsColumns, insertAt, numberOfNewRows); |
| | 0 | 591 | | InsertRowsOfTypeInternal(ref allBoundsIntColumns, insertAt, numberOfNewRows); |
| | 0 | 592 | | InsertRowsOfTypeInternal(ref allHash128Columns, insertAt, numberOfNewRows); |
| | 0 | 593 | | InsertRowsOfTypeInternal(ref allGradientColumns, insertAt, numberOfNewRows); |
| | 0 | 594 | | InsertRowsOfTypeInternal(ref allAnimationCurveColumns, insertAt, numberOfNewRows); |
| | 0 | 595 | | InsertRowsOfTypeInternal(ref allObjectRefColumns, insertAt, numberOfNewRows); |
| | | 596 | | |
| | 0 | 597 | | rowCount += numberOfNewRows; |
| | 0 | 598 | | dataVersion++; |
| | 0 | 599 | | } |
| | | 600 | | |
| | | 601 | | public void RemoveRow(int rowID) |
| | 0 | 602 | | { |
| | 0 | 603 | | AssertRowIDValid(rowID); |
| | 0 | 604 | | int rowDenseIndex = rowIDToDenseIndexMap[rowID]; |
| | 0 | 605 | | for (int i = rowDenseIndex + 1; i < rowCount; i++) |
| | 0 | 606 | | { |
| | 0 | 607 | | int currentRowID = rowDenseIndexToIDMap[i]; |
| | 0 | 608 | | rowIDToDenseIndexMap[currentRowID] = i - 1; |
| | 0 | 609 | | rowDenseIndexToIDMap[i - 1] = currentRowID; |
| | 0 | 610 | | rowNames[i - 1] = rowNames[i]; |
| | 0 | 611 | | } |
| | | 612 | | |
| | 0 | 613 | | rowIDToDenseIndexMap[rowID] = rowEntriesFreeListHead; |
| | 0 | 614 | | rowEntriesFreeListHead = rowID; |
| | 0 | 615 | | Array.Resize(ref rowDenseIndexToIDMap, rowCount - 1); |
| | 0 | 616 | | Array.Resize(ref rowNames, rowCount - 1); |
| | | 617 | | |
| | 0 | 618 | | DeleteRowsOfTypeInternal(ref allStringColumns, rowID, 1); |
| | 0 | 619 | | DeleteRowsOfTypeInternal(ref allBoolColumns, rowID, 1); |
| | 0 | 620 | | DeleteRowsOfTypeInternal(ref allCharColumns, rowID, 1); |
| | 0 | 621 | | DeleteRowsOfTypeInternal(ref allSbyteColumns, rowID, 1); |
| | 0 | 622 | | DeleteRowsOfTypeInternal(ref allByteColumns, rowID, 1); |
| | 0 | 623 | | DeleteRowsOfTypeInternal(ref allShortColumns, rowID, 1); |
| | 0 | 624 | | DeleteRowsOfTypeInternal(ref allUshortColumns, rowID, 1); |
| | 0 | 625 | | DeleteRowsOfTypeInternal(ref allIntColumns, rowID, 1); |
| | 0 | 626 | | DeleteRowsOfTypeInternal(ref allUintColumns, rowID, 1); |
| | 0 | 627 | | DeleteRowsOfTypeInternal(ref allLongColumns, rowID, 1); |
| | 0 | 628 | | DeleteRowsOfTypeInternal(ref allUlongColumns, rowID, 1); |
| | 0 | 629 | | DeleteRowsOfTypeInternal(ref allFloatColumns, rowID, 1); |
| | 0 | 630 | | DeleteRowsOfTypeInternal(ref allDoubleColumns, rowID, 1); |
| | 0 | 631 | | DeleteRowsOfTypeInternal(ref allVector2Columns, rowID, 1); |
| | 0 | 632 | | DeleteRowsOfTypeInternal(ref allVector3Columns, rowID, 1); |
| | 0 | 633 | | DeleteRowsOfTypeInternal(ref allVector4Columns, rowID, 1); |
| | 0 | 634 | | DeleteRowsOfTypeInternal(ref allVector2IntColumns, rowID, 1); |
| | 0 | 635 | | DeleteRowsOfTypeInternal(ref allVector3IntColumns, rowID, 1); |
| | 0 | 636 | | DeleteRowsOfTypeInternal(ref allQuaternionColumns, rowID, 1); |
| | 0 | 637 | | DeleteRowsOfTypeInternal(ref allRectColumns, rowID, 1); |
| | 0 | 638 | | DeleteRowsOfTypeInternal(ref allRectIntColumns, rowID, 1); |
| | 0 | 639 | | DeleteRowsOfTypeInternal(ref allColorColumns, rowID, 1); |
| | 0 | 640 | | DeleteRowsOfTypeInternal(ref allLayerMaskColumns, rowID, 1); |
| | 0 | 641 | | DeleteRowsOfTypeInternal(ref allBoundsColumns, rowID, 1); |
| | 0 | 642 | | DeleteRowsOfTypeInternal(ref allBoundsIntColumns, rowID, 1); |
| | 0 | 643 | | DeleteRowsOfTypeInternal(ref allHash128Columns, rowID, 1); |
| | 0 | 644 | | DeleteRowsOfTypeInternal(ref allGradientColumns, rowID, 1); |
| | 0 | 645 | | DeleteRowsOfTypeInternal(ref allAnimationCurveColumns, rowID, 1); |
| | 0 | 646 | | DeleteRowsOfTypeInternal(ref allObjectRefColumns, rowID, 1); |
| | | 647 | | |
| | 0 | 648 | | --rowCount; |
| | 0 | 649 | | dataVersion++; |
| | 0 | 650 | | } |
| | | 651 | | |
| | | 652 | | public int AddColumn(Serializable.SerializableTypes columnType, string columnName, int insertAtColumnID = -1) |
| | 0 | 653 | | { |
| | 0 | 654 | | switch (columnType) |
| | | 655 | | { |
| | | 656 | | case Serializable.SerializableTypes.String: |
| | 0 | 657 | | return AddColumnInternal(columnName, ref allStringColumns, Serializable.SerializableTypes.String, in |
| | | 658 | | case Serializable.SerializableTypes.Char: |
| | 0 | 659 | | return AddColumnInternal(columnName, ref allCharColumns, Serializable.SerializableTypes.Char, insert |
| | | 660 | | case Serializable.SerializableTypes.Bool: |
| | 0 | 661 | | return AddColumnInternal(columnName, ref allBoolColumns, Serializable.SerializableTypes.Bool, insert |
| | | 662 | | case Serializable.SerializableTypes.SByte: |
| | 0 | 663 | | return AddColumnInternal(columnName, ref allSbyteColumns, Serializable.SerializableTypes.SByte, inse |
| | | 664 | | case Serializable.SerializableTypes.Byte: |
| | 0 | 665 | | return AddColumnInternal(columnName, ref allByteColumns, Serializable.SerializableTypes.Byte, insert |
| | | 666 | | case Serializable.SerializableTypes.Short: |
| | 0 | 667 | | return AddColumnInternal(columnName, ref allShortColumns, Serializable.SerializableTypes.Short, inse |
| | | 668 | | case Serializable.SerializableTypes.UShort: |
| | 0 | 669 | | return AddColumnInternal(columnName, ref allUshortColumns, Serializable.SerializableTypes.UShort, in |
| | | 670 | | case Serializable.SerializableTypes.Int: |
| | 0 | 671 | | return AddColumnInternal(columnName, ref allIntColumns, Serializable.SerializableTypes.Int, insertAt |
| | | 672 | | case Serializable.SerializableTypes.UInt: |
| | 0 | 673 | | return AddColumnInternal(columnName, ref allUintColumns, Serializable.SerializableTypes.UInt, insert |
| | | 674 | | case Serializable.SerializableTypes.Long: |
| | 0 | 675 | | return AddColumnInternal(columnName, ref allLongColumns, Serializable.SerializableTypes.Long, insert |
| | | 676 | | case Serializable.SerializableTypes.ULong: |
| | 0 | 677 | | return AddColumnInternal(columnName, ref allUlongColumns, Serializable.SerializableTypes.ULong, inse |
| | | 678 | | case Serializable.SerializableTypes.Float: |
| | 0 | 679 | | return AddColumnInternal(columnName, ref allFloatColumns, Serializable.SerializableTypes.Float, inse |
| | | 680 | | case Serializable.SerializableTypes.Double: |
| | 0 | 681 | | return AddColumnInternal(columnName, ref allDoubleColumns, Serializable.SerializableTypes.Double, in |
| | | 682 | | case Serializable.SerializableTypes.Vector2: |
| | 0 | 683 | | return AddColumnInternal(columnName, ref allVector2Columns, Serializable.SerializableTypes.Vector2, |
| | | 684 | | case Serializable.SerializableTypes.Vector3: |
| | 0 | 685 | | return AddColumnInternal(columnName, ref allVector3Columns, Serializable.SerializableTypes.Vector3, |
| | | 686 | | case Serializable.SerializableTypes.Vector4: |
| | 0 | 687 | | return AddColumnInternal(columnName, ref allVector4Columns, Serializable.SerializableTypes.Vector4, |
| | | 688 | | case Serializable.SerializableTypes.Vector2Int: |
| | 0 | 689 | | return AddColumnInternal(columnName, ref allVector2IntColumns, Serializable.SerializableTypes.Vector |
| | | 690 | | case Serializable.SerializableTypes.Vector3Int: |
| | 0 | 691 | | return AddColumnInternal(columnName, ref allVector3IntColumns, Serializable.SerializableTypes.Vector |
| | | 692 | | case Serializable.SerializableTypes.Quaternion: |
| | 0 | 693 | | return AddColumnInternal(columnName, ref allQuaternionColumns, Serializable.SerializableTypes.Quater |
| | | 694 | | case Serializable.SerializableTypes.Rect: |
| | 0 | 695 | | return AddColumnInternal(columnName, ref allRectColumns, Serializable.SerializableTypes.Rect, insert |
| | | 696 | | case Serializable.SerializableTypes.RectInt: |
| | 0 | 697 | | return AddColumnInternal(columnName, ref allRectIntColumns, Serializable.SerializableTypes.RectInt, |
| | | 698 | | case Serializable.SerializableTypes.Color: |
| | 0 | 699 | | return AddColumnInternal(columnName, ref allColorColumns, Serializable.SerializableTypes.Color, inse |
| | | 700 | | case Serializable.SerializableTypes.LayerMask: |
| | 0 | 701 | | return AddColumnInternal(columnName, ref allLayerMaskColumns, Serializable.SerializableTypes.LayerMa |
| | | 702 | | case Serializable.SerializableTypes.Bounds: |
| | 0 | 703 | | return AddColumnInternal(columnName, ref allBoundsColumns, Serializable.SerializableTypes.Bounds, in |
| | | 704 | | case Serializable.SerializableTypes.BoundsInt: |
| | 0 | 705 | | return AddColumnInternal(columnName, ref allBoundsIntColumns, Serializable.SerializableTypes.BoundsI |
| | | 706 | | case Serializable.SerializableTypes.Hash128: |
| | 0 | 707 | | return AddColumnInternal(columnName, ref allHash128Columns, Serializable.SerializableTypes.Hash128, |
| | | 708 | | case Serializable.SerializableTypes.Gradient: |
| | 0 | 709 | | return AddColumnInternal(columnName, ref allGradientColumns, Serializable.SerializableTypes.Gradient |
| | | 710 | | case Serializable.SerializableTypes.AnimationCurve: |
| | 0 | 711 | | return AddColumnInternal(columnName, ref allAnimationCurveColumns, Serializable.SerializableTypes.An |
| | | 712 | | case Serializable.SerializableTypes.Object: |
| | 0 | 713 | | return AddColumnInternal(columnName, ref allObjectRefColumns, Serializable.SerializableTypes.Object, |
| | | 714 | | } |
| | 0 | 715 | | return -1; |
| | 0 | 716 | | } |
| | | 717 | | |
| | | 718 | | public void RemoveColumn(Serializable.SerializableTypes columnType, int columnID) |
| | 0 | 719 | | { |
| | 0 | 720 | | switch (columnType) |
| | | 721 | | { |
| | | 722 | | case Serializable.SerializableTypes.String: |
| | 0 | 723 | | RemoveColumnInternal(ref allStringColumns, Serializable.SerializableTypes.String, columnID); |
| | 0 | 724 | | break; |
| | | 725 | | case Serializable.SerializableTypes.Char: |
| | 0 | 726 | | RemoveColumnInternal(ref allCharColumns, Serializable.SerializableTypes.Char, columnID); |
| | 0 | 727 | | break; |
| | | 728 | | case Serializable.SerializableTypes.Bool: |
| | 0 | 729 | | RemoveColumnInternal(ref allBoolColumns, Serializable.SerializableTypes.Bool, columnID); |
| | 0 | 730 | | break; |
| | | 731 | | case Serializable.SerializableTypes.SByte: |
| | 0 | 732 | | RemoveColumnInternal(ref allSbyteColumns, Serializable.SerializableTypes.SByte, columnID); |
| | 0 | 733 | | break; |
| | | 734 | | case Serializable.SerializableTypes.Byte: |
| | 0 | 735 | | RemoveColumnInternal(ref allByteColumns, Serializable.SerializableTypes.Byte, columnID); |
| | 0 | 736 | | break; |
| | | 737 | | case Serializable.SerializableTypes.Short: |
| | 0 | 738 | | RemoveColumnInternal(ref allShortColumns, Serializable.SerializableTypes.Short, columnID); |
| | 0 | 739 | | break; |
| | | 740 | | case Serializable.SerializableTypes.UShort: |
| | 0 | 741 | | RemoveColumnInternal(ref allUshortColumns, Serializable.SerializableTypes.UShort, columnID); |
| | 0 | 742 | | break; |
| | | 743 | | case Serializable.SerializableTypes.Int: |
| | 0 | 744 | | RemoveColumnInternal(ref allIntColumns, Serializable.SerializableTypes.Int, columnID); |
| | 0 | 745 | | break; |
| | | 746 | | case Serializable.SerializableTypes.UInt: |
| | 0 | 747 | | RemoveColumnInternal(ref allUintColumns, Serializable.SerializableTypes.UInt, columnID); |
| | 0 | 748 | | break; |
| | | 749 | | case Serializable.SerializableTypes.Long: |
| | 0 | 750 | | RemoveColumnInternal(ref allLongColumns, Serializable.SerializableTypes.Long, columnID); |
| | 0 | 751 | | break; |
| | | 752 | | case Serializable.SerializableTypes.ULong: |
| | 0 | 753 | | RemoveColumnInternal(ref allUlongColumns, Serializable.SerializableTypes.ULong, columnID); |
| | 0 | 754 | | break; |
| | | 755 | | case Serializable.SerializableTypes.Float: |
| | 0 | 756 | | RemoveColumnInternal(ref allFloatColumns, Serializable.SerializableTypes.Float, columnID); |
| | 0 | 757 | | break; |
| | | 758 | | case Serializable.SerializableTypes.Double: |
| | 0 | 759 | | RemoveColumnInternal(ref allDoubleColumns, Serializable.SerializableTypes.Double, columnID); |
| | 0 | 760 | | break; |
| | | 761 | | case Serializable.SerializableTypes.Vector2: |
| | 0 | 762 | | RemoveColumnInternal(ref allVector2Columns, Serializable.SerializableTypes.Vector2, columnID); |
| | 0 | 763 | | break; |
| | | 764 | | case Serializable.SerializableTypes.Vector3: |
| | 0 | 765 | | RemoveColumnInternal(ref allVector3Columns, Serializable.SerializableTypes.Vector3, columnID); |
| | 0 | 766 | | break; |
| | | 767 | | case Serializable.SerializableTypes.Vector4: |
| | 0 | 768 | | RemoveColumnInternal(ref allVector4Columns, Serializable.SerializableTypes.Vector4, columnID); |
| | 0 | 769 | | break; |
| | | 770 | | case Serializable.SerializableTypes.Vector2Int: |
| | 0 | 771 | | RemoveColumnInternal(ref allVector2IntColumns, Serializable.SerializableTypes.Vector2Int, columnID); |
| | 0 | 772 | | break; |
| | | 773 | | case Serializable.SerializableTypes.Vector3Int: |
| | 0 | 774 | | RemoveColumnInternal(ref allVector3IntColumns, Serializable.SerializableTypes.Vector3Int, columnID); |
| | 0 | 775 | | break; |
| | | 776 | | case Serializable.SerializableTypes.Quaternion: |
| | 0 | 777 | | RemoveColumnInternal(ref allQuaternionColumns, Serializable.SerializableTypes.Quaternion, columnID); |
| | 0 | 778 | | break; |
| | | 779 | | case Serializable.SerializableTypes.Rect: |
| | 0 | 780 | | RemoveColumnInternal(ref allRectColumns, Serializable.SerializableTypes.Rect, columnID); |
| | 0 | 781 | | break; |
| | | 782 | | case Serializable.SerializableTypes.RectInt: |
| | 0 | 783 | | RemoveColumnInternal(ref allRectIntColumns, Serializable.SerializableTypes.RectInt, columnID); |
| | 0 | 784 | | break; |
| | | 785 | | case Serializable.SerializableTypes.Color: |
| | 0 | 786 | | RemoveColumnInternal(ref allColorColumns, Serializable.SerializableTypes.Color, columnID); |
| | 0 | 787 | | break; |
| | | 788 | | case Serializable.SerializableTypes.LayerMask: |
| | 0 | 789 | | RemoveColumnInternal(ref allLayerMaskColumns, Serializable.SerializableTypes.LayerMask, columnID); |
| | 0 | 790 | | break; |
| | | 791 | | case Serializable.SerializableTypes.Bounds: |
| | 0 | 792 | | RemoveColumnInternal(ref allBoundsColumns, Serializable.SerializableTypes.Bounds, columnID); |
| | 0 | 793 | | break; |
| | | 794 | | case Serializable.SerializableTypes.BoundsInt: |
| | 0 | 795 | | RemoveColumnInternal(ref allBoundsIntColumns, Serializable.SerializableTypes.BoundsInt, columnID); |
| | 0 | 796 | | break; |
| | | 797 | | case Serializable.SerializableTypes.Hash128: |
| | 0 | 798 | | RemoveColumnInternal(ref allHash128Columns, Serializable.SerializableTypes.Hash128, columnID); |
| | 0 | 799 | | break; |
| | | 800 | | case Serializable.SerializableTypes.Gradient: |
| | 0 | 801 | | RemoveColumnInternal(ref allGradientColumns, Serializable.SerializableTypes.Gradient, columnID); |
| | 0 | 802 | | break; |
| | | 803 | | case Serializable.SerializableTypes.AnimationCurve: |
| | 0 | 804 | | RemoveColumnInternal(ref allAnimationCurveColumns, Serializable.SerializableTypes.AnimationCurve, co |
| | 0 | 805 | | break; |
| | | 806 | | case Serializable.SerializableTypes.Object: |
| | 0 | 807 | | RemoveColumnInternal(ref allObjectRefColumns, Serializable.SerializableTypes.Object, columnID); |
| | 0 | 808 | | break; |
| | | 809 | | } |
| | 0 | 810 | | } |
| | | 811 | | |
| | | 812 | | // Set |
| | | 813 | | |
| | | 814 | | public ulong SetString(int row, int column, string value) |
| | 0 | 815 | | { |
| | 0 | 816 | | return SetCell(row, column, ref allStringColumns, value); |
| | 0 | 817 | | } |
| | | 818 | | |
| | | 819 | | public ulong SetBool(int row, int column, bool value) |
| | 0 | 820 | | { |
| | 0 | 821 | | return SetCell(row, column, ref allBoolColumns, value); |
| | 0 | 822 | | } |
| | | 823 | | |
| | | 824 | | public ulong SetChar(int row, int column, char value) |
| | 0 | 825 | | { |
| | 0 | 826 | | return SetCell(row, column, ref allCharColumns, value); |
| | 0 | 827 | | } |
| | | 828 | | |
| | | 829 | | public ulong SetSByte(int row, int column, sbyte value) |
| | 0 | 830 | | { |
| | 0 | 831 | | return SetCell(row, column, ref allSbyteColumns, value); |
| | 0 | 832 | | } |
| | | 833 | | |
| | | 834 | | public ulong SetByte(int row, int column, byte value) |
| | 0 | 835 | | { |
| | 0 | 836 | | return SetCell(row, column, ref allByteColumns, value); |
| | 0 | 837 | | } |
| | | 838 | | |
| | | 839 | | public ulong SetShort(int row, int column, short value) |
| | 0 | 840 | | { |
| | 0 | 841 | | return SetCell(row, column, ref allShortColumns, value); |
| | 0 | 842 | | } |
| | | 843 | | |
| | | 844 | | public ulong SetUShort(int row, int column, ushort value) |
| | 0 | 845 | | { |
| | 0 | 846 | | return SetCell(row, column, ref allUshortColumns, value); |
| | 0 | 847 | | } |
| | | 848 | | |
| | | 849 | | public ulong SetInt(int row, int column, int value) |
| | 0 | 850 | | { |
| | 0 | 851 | | return SetCell(row, column, ref allIntColumns, value); |
| | 0 | 852 | | } |
| | | 853 | | |
| | | 854 | | public ulong SetUInt(int row, int column, uint value) |
| | 0 | 855 | | { |
| | 0 | 856 | | return SetCell(row, column, ref allUintColumns, value); |
| | 0 | 857 | | } |
| | | 858 | | |
| | | 859 | | public ulong SetLong(int row, int column, long value) |
| | 0 | 860 | | { |
| | 0 | 861 | | return SetCell(row, column, ref allLongColumns, value); |
| | 0 | 862 | | } |
| | | 863 | | |
| | | 864 | | public ulong SetULong(int row, int column, ulong value) |
| | 0 | 865 | | { |
| | 0 | 866 | | return SetCell(row, column, ref allUlongColumns, value); |
| | 0 | 867 | | } |
| | | 868 | | |
| | | 869 | | public ulong SetFloat(int row, int column, float value) |
| | 0 | 870 | | { |
| | 0 | 871 | | return SetCell(row, column, ref allFloatColumns, value); |
| | 0 | 872 | | } |
| | | 873 | | |
| | | 874 | | public ulong SetDouble(int row, int column, double value) |
| | 0 | 875 | | { |
| | 0 | 876 | | return SetCell(row, column, ref allDoubleColumns, value); |
| | 0 | 877 | | } |
| | | 878 | | |
| | | 879 | | public ulong SetVector2(int row, int column, Vector2 value) |
| | 0 | 880 | | { |
| | 0 | 881 | | return SetCell(row, column, ref allVector2Columns, value); |
| | 0 | 882 | | } |
| | | 883 | | |
| | | 884 | | public ulong SetVector3(int row, int column, Vector3 value) |
| | 0 | 885 | | { |
| | 0 | 886 | | return SetCell(row, column, ref allVector3Columns, value); |
| | 0 | 887 | | } |
| | | 888 | | |
| | | 889 | | public ulong SetVector4(int row, int column, Vector4 value) |
| | 0 | 890 | | { |
| | 0 | 891 | | return SetCell(row, column, ref allVector4Columns, value); |
| | 0 | 892 | | } |
| | | 893 | | |
| | | 894 | | public ulong SetVector2Int(int row, int column, Vector2Int value) |
| | 0 | 895 | | { |
| | 0 | 896 | | return SetCell(row, column, ref allVector2IntColumns, value); |
| | 0 | 897 | | } |
| | | 898 | | |
| | | 899 | | public ulong SetVector3Int(int row, int column, Vector3Int value) |
| | 0 | 900 | | { |
| | 0 | 901 | | return SetCell(row, column, ref allVector3IntColumns, value); |
| | 0 | 902 | | } |
| | | 903 | | |
| | | 904 | | public ulong SetQuaternion(int row, int column, Quaternion value) |
| | 0 | 905 | | { |
| | 0 | 906 | | return SetCell(row, column, ref allQuaternionColumns, value); |
| | 0 | 907 | | } |
| | | 908 | | |
| | | 909 | | public ulong SetRect(int row, int column, Rect value) |
| | 0 | 910 | | { |
| | 0 | 911 | | return SetCell(row, column, ref allRectColumns, value); |
| | 0 | 912 | | } |
| | | 913 | | |
| | | 914 | | public ulong SetRectInt(int row, int column, RectInt value) |
| | 0 | 915 | | { |
| | 0 | 916 | | return SetCell(row, column, ref allRectIntColumns, value); |
| | 0 | 917 | | } |
| | | 918 | | |
| | | 919 | | public ulong SetColor(int row, int column, Color value) |
| | 0 | 920 | | { |
| | 0 | 921 | | return SetCell(row, column, ref allColorColumns, value); |
| | 0 | 922 | | } |
| | | 923 | | |
| | | 924 | | public ulong SetLayerMask(int row, int column, LayerMask value) |
| | 0 | 925 | | { |
| | 0 | 926 | | return SetCell(row, column, ref allLayerMaskColumns, value); |
| | 0 | 927 | | } |
| | | 928 | | |
| | | 929 | | public ulong SetBounds(int row, int column, Bounds value) |
| | 0 | 930 | | { |
| | 0 | 931 | | return SetCell(row, column, ref allBoundsColumns, value); |
| | 0 | 932 | | } |
| | | 933 | | |
| | | 934 | | public ulong SetBoundsInt(int row, int column, BoundsInt value) |
| | 0 | 935 | | { |
| | 0 | 936 | | return SetCell(row, column, ref allBoundsIntColumns, value); |
| | 0 | 937 | | } |
| | | 938 | | |
| | | 939 | | public ulong SetHash128(int row, int column, Hash128 value) |
| | 0 | 940 | | { |
| | 0 | 941 | | return SetCell(row, column, ref allHash128Columns, value); |
| | 0 | 942 | | } |
| | | 943 | | |
| | | 944 | | public ulong SetGradient(int row, int column, Gradient value) |
| | 0 | 945 | | { |
| | 0 | 946 | | return SetCell(row, column, ref allGradientColumns, value); |
| | 0 | 947 | | } |
| | | 948 | | |
| | | 949 | | public ulong SetAnimationCurve(int row, int column, AnimationCurve value) |
| | 0 | 950 | | { |
| | 0 | 951 | | return SetCell(row, column, ref allAnimationCurveColumns, value); |
| | 0 | 952 | | } |
| | | 953 | | |
| | | 954 | | public ulong SetObject(int row, int column, UnityEngine.Object value) |
| | 0 | 955 | | { |
| | 0 | 956 | | return SetCell(row, column, ref allObjectRefColumns, value); |
| | 0 | 957 | | } |
| | | 958 | | |
| | | 959 | | // Get |
| | | 960 | | public string GetString(int row, int column) |
| | 0 | 961 | | { |
| | 0 | 962 | | return GetCell(row, column, ref allStringColumns); |
| | 0 | 963 | | } |
| | | 964 | | |
| | | 965 | | public bool GetBool(int row, int column) |
| | 0 | 966 | | { |
| | 0 | 967 | | return GetCell(row, column, ref allBoolColumns); |
| | 0 | 968 | | } |
| | | 969 | | |
| | | 970 | | public char GetChar(int row, int column) |
| | 0 | 971 | | { |
| | 0 | 972 | | return GetCell(row, column, ref allCharColumns); |
| | 0 | 973 | | } |
| | | 974 | | |
| | | 975 | | public sbyte GetSByte(int row, int column) |
| | 0 | 976 | | { |
| | 0 | 977 | | return GetCell(row, column, ref allSbyteColumns); |
| | 0 | 978 | | } |
| | | 979 | | |
| | | 980 | | public byte GetByte(int row, int column) |
| | 0 | 981 | | { |
| | 0 | 982 | | return GetCell(row, column, ref allByteColumns); |
| | 0 | 983 | | } |
| | | 984 | | |
| | | 985 | | public short GetShort(int row, int column) |
| | 0 | 986 | | { |
| | 0 | 987 | | return GetCell(row, column, ref allShortColumns); |
| | 0 | 988 | | } |
| | | 989 | | |
| | | 990 | | public ushort GetUShort(int row, int column) |
| | 0 | 991 | | { |
| | 0 | 992 | | return GetCell(row, column, ref allUshortColumns); |
| | 0 | 993 | | } |
| | | 994 | | |
| | | 995 | | public int GetInt(int row, int column) |
| | 0 | 996 | | { |
| | 0 | 997 | | return GetCell(row, column, ref allIntColumns); |
| | 0 | 998 | | } |
| | | 999 | | |
| | | 1000 | | public uint GetUInt(int row, int column) |
| | 0 | 1001 | | { |
| | 0 | 1002 | | return GetCell(row, column, ref allUintColumns); |
| | 0 | 1003 | | } |
| | | 1004 | | |
| | | 1005 | | public long GetLong(int row, int column) |
| | 0 | 1006 | | { |
| | 0 | 1007 | | return GetCell(row, column, ref allLongColumns); |
| | 0 | 1008 | | } |
| | | 1009 | | |
| | | 1010 | | public ulong GetULong(int row, int column) |
| | 0 | 1011 | | { |
| | 0 | 1012 | | return GetCell(row, column, ref allUlongColumns); |
| | 0 | 1013 | | } |
| | | 1014 | | |
| | | 1015 | | public float GetFloat(int row, int column) |
| | 0 | 1016 | | { |
| | 0 | 1017 | | return GetCell(row, column, ref allFloatColumns); |
| | 0 | 1018 | | } |
| | | 1019 | | |
| | | 1020 | | public double GetDouble(int row, int column) |
| | 0 | 1021 | | { |
| | 0 | 1022 | | return GetCell(row, column, ref allDoubleColumns); |
| | 0 | 1023 | | } |
| | | 1024 | | |
| | | 1025 | | public Vector2 GetVector2(int row, int column) |
| | 0 | 1026 | | { |
| | 0 | 1027 | | return GetCell(row, column, ref allVector2Columns); |
| | 0 | 1028 | | } |
| | | 1029 | | |
| | | 1030 | | public Vector3 GetVector3(int row, int column) |
| | 0 | 1031 | | { |
| | 0 | 1032 | | return GetCell(row, column, ref allVector3Columns); |
| | 0 | 1033 | | } |
| | | 1034 | | |
| | | 1035 | | public Vector4 GetVector4(int row, int column) |
| | 0 | 1036 | | { |
| | 0 | 1037 | | return GetCell(row, column, ref allVector4Columns); |
| | 0 | 1038 | | } |
| | | 1039 | | |
| | | 1040 | | public Vector2Int GetVector2Int(int row, int column) |
| | 0 | 1041 | | { |
| | 0 | 1042 | | return GetCell(row, column, ref allVector2IntColumns); |
| | 0 | 1043 | | } |
| | | 1044 | | |
| | | 1045 | | public Vector3Int GetVector3Int(int row, int column) |
| | 0 | 1046 | | { |
| | 0 | 1047 | | return GetCell(row, column, ref allVector3IntColumns); |
| | 0 | 1048 | | } |
| | | 1049 | | |
| | | 1050 | | public Quaternion GetQuaternion(int row, int column) |
| | 0 | 1051 | | { |
| | 0 | 1052 | | return GetCell(row, column, ref allQuaternionColumns); |
| | 0 | 1053 | | } |
| | | 1054 | | |
| | | 1055 | | public Rect GetRect(int row, int column) |
| | 0 | 1056 | | { |
| | 0 | 1057 | | return GetCell(row, column, ref allRectColumns); |
| | 0 | 1058 | | } |
| | | 1059 | | |
| | | 1060 | | public RectInt GetRectInt(int row, int column) |
| | 0 | 1061 | | { |
| | 0 | 1062 | | return GetCell(row, column, ref allRectIntColumns); |
| | 0 | 1063 | | } |
| | | 1064 | | |
| | | 1065 | | public Color GetColor(int row, int column) |
| | 0 | 1066 | | { |
| | 0 | 1067 | | return GetCell(row, column, ref allColorColumns); |
| | 0 | 1068 | | } |
| | | 1069 | | |
| | | 1070 | | public LayerMask GetLayerMask(int row, int column) |
| | 0 | 1071 | | { |
| | 0 | 1072 | | return GetCell(row, column, ref allLayerMaskColumns); |
| | 0 | 1073 | | } |
| | | 1074 | | |
| | | 1075 | | public Bounds GetBounds(int row, int column) |
| | 0 | 1076 | | { |
| | 0 | 1077 | | return GetCell(row, column, ref allBoundsColumns); |
| | 0 | 1078 | | } |
| | | 1079 | | |
| | | 1080 | | public BoundsInt GetBoundsInt(int row, int column) |
| | 0 | 1081 | | { |
| | 0 | 1082 | | return GetCell(row, column, ref allBoundsIntColumns); |
| | 0 | 1083 | | } |
| | | 1084 | | |
| | | 1085 | | public Hash128 GetHash128(int row, int column) |
| | 0 | 1086 | | { |
| | 0 | 1087 | | return GetCell(row, column, ref allHash128Columns); |
| | 0 | 1088 | | } |
| | | 1089 | | |
| | | 1090 | | public Gradient GetGradient(int row, int column) |
| | 0 | 1091 | | { |
| | 0 | 1092 | | return GetCell(row, column, ref allGradientColumns); |
| | 0 | 1093 | | } |
| | | 1094 | | |
| | | 1095 | | public AnimationCurve GetAnimationCurve(int row, int column) |
| | 0 | 1096 | | { |
| | 0 | 1097 | | return GetCell(row, column, ref allAnimationCurveColumns); |
| | 0 | 1098 | | } |
| | | 1099 | | |
| | | 1100 | | public UnityEngine.Object GetObject(int row, int column) |
| | 0 | 1101 | | { |
| | 0 | 1102 | | return GetCell(row, column, ref allObjectRefColumns); |
| | 0 | 1103 | | } |
| | | 1104 | | |
| | | 1105 | | // Get ref |
| | | 1106 | | |
| | | 1107 | | public ref string GetStringRef(int row, int column) |
| | 0 | 1108 | | { |
| | 0 | 1109 | | return ref GetCellRef(row, column, ref allStringColumns); |
| | 0 | 1110 | | } |
| | | 1111 | | |
| | | 1112 | | public ref bool GetBoolRef(int row, int column) |
| | 0 | 1113 | | { |
| | 0 | 1114 | | return ref GetCellRef(row, column, ref allBoolColumns); |
| | 0 | 1115 | | } |
| | | 1116 | | |
| | | 1117 | | public ref char GetCharRef(int row, int column) |
| | 0 | 1118 | | { |
| | 0 | 1119 | | return ref GetCellRef(row, column, ref allCharColumns); |
| | 0 | 1120 | | } |
| | | 1121 | | |
| | | 1122 | | public ref sbyte GetSbyteRef(int row, int column) |
| | 0 | 1123 | | { |
| | 0 | 1124 | | return ref GetCellRef(row, column, ref allSbyteColumns); |
| | 0 | 1125 | | } |
| | | 1126 | | |
| | | 1127 | | public ref byte GetByteRef(int row, int columnID) |
| | 0 | 1128 | | { |
| | 0 | 1129 | | return ref GetCellRef(row, columnID, ref allByteColumns); |
| | 0 | 1130 | | } |
| | | 1131 | | |
| | | 1132 | | public ref short GetShortRef(int row, int column) |
| | 0 | 1133 | | { |
| | 0 | 1134 | | return ref GetCellRef(row, column, ref allShortColumns); |
| | 0 | 1135 | | } |
| | | 1136 | | |
| | | 1137 | | public ref ushort GetUshortRef(int row, int column) |
| | 0 | 1138 | | { |
| | 0 | 1139 | | return ref GetCellRef(row, column, ref allUshortColumns); |
| | 0 | 1140 | | } |
| | | 1141 | | |
| | | 1142 | | public ref int GetIntRef(int row, int column) |
| | 0 | 1143 | | { |
| | 0 | 1144 | | return ref GetCellRef(row, column, ref allIntColumns); |
| | 0 | 1145 | | } |
| | | 1146 | | |
| | | 1147 | | public ref uint GetUintRef(int row, int column) |
| | 0 | 1148 | | { |
| | 0 | 1149 | | return ref GetCellRef(row, column, ref allUintColumns); |
| | 0 | 1150 | | } |
| | | 1151 | | |
| | | 1152 | | public ref long GetLongRef(int row, int column) |
| | 0 | 1153 | | { |
| | 0 | 1154 | | return ref GetCellRef(row, column, ref allLongColumns); |
| | 0 | 1155 | | } |
| | | 1156 | | |
| | | 1157 | | public ref ulong GetUlongRef(int row, int column) |
| | 0 | 1158 | | { |
| | 0 | 1159 | | return ref GetCellRef(row, column, ref allUlongColumns); |
| | 0 | 1160 | | } |
| | | 1161 | | |
| | | 1162 | | public ref float GetFloatRef(int row, int column) |
| | 0 | 1163 | | { |
| | 0 | 1164 | | return ref GetCellRef(row, column, ref allFloatColumns); |
| | 0 | 1165 | | } |
| | | 1166 | | |
| | | 1167 | | public ref double GetDoubleRef(int row, int column) |
| | 0 | 1168 | | { |
| | 0 | 1169 | | return ref GetCellRef(row, column, ref allDoubleColumns); |
| | 0 | 1170 | | } |
| | | 1171 | | |
| | | 1172 | | public ref Vector2 GetVector2Ref(int row, int column) |
| | 0 | 1173 | | { |
| | 0 | 1174 | | return ref GetCellRef(row, column, ref allVector2Columns); |
| | 0 | 1175 | | } |
| | | 1176 | | |
| | | 1177 | | public ref Vector3 GetVector3Ref(int row, int column) |
| | 0 | 1178 | | { |
| | 0 | 1179 | | return ref GetCellRef(row, column, ref allVector3Columns); |
| | 0 | 1180 | | } |
| | | 1181 | | |
| | | 1182 | | public ref Vector4 GetVector4Ref(int row, int column) |
| | 0 | 1183 | | { |
| | 0 | 1184 | | return ref GetCellRef(row, column, ref allVector4Columns); |
| | 0 | 1185 | | } |
| | | 1186 | | |
| | | 1187 | | public ref Vector2Int GetVector2IntRef(int row, int column) |
| | 0 | 1188 | | { |
| | 0 | 1189 | | return ref GetCellRef(row, column, ref allVector2IntColumns); |
| | 0 | 1190 | | } |
| | | 1191 | | |
| | | 1192 | | public ref Vector3Int GetVector3IntRef(int row, int column) |
| | 0 | 1193 | | { |
| | 0 | 1194 | | return ref GetCellRef(row, column, ref allVector3IntColumns); |
| | 0 | 1195 | | } |
| | | 1196 | | |
| | | 1197 | | public ref Quaternion GetQuaternionRef(int row, int column) |
| | 0 | 1198 | | { |
| | 0 | 1199 | | return ref GetCellRef(row, column, ref allQuaternionColumns); |
| | 0 | 1200 | | } |
| | | 1201 | | |
| | | 1202 | | public ref Rect GetRectRef(int row, int column) |
| | 0 | 1203 | | { |
| | 0 | 1204 | | return ref GetCellRef(row, column, ref allRectColumns); |
| | 0 | 1205 | | } |
| | | 1206 | | |
| | | 1207 | | public ref RectInt GetRectIntRef(int row, int column) |
| | 0 | 1208 | | { |
| | 0 | 1209 | | return ref GetCellRef(row, column, ref allRectIntColumns); |
| | 0 | 1210 | | } |
| | | 1211 | | |
| | | 1212 | | public ref Color GetColorRef(int row, int column) |
| | 0 | 1213 | | { |
| | 0 | 1214 | | return ref GetCellRef(row, column, ref allColorColumns); |
| | 0 | 1215 | | } |
| | | 1216 | | |
| | | 1217 | | public ref LayerMask GetLayerMaskRef(int row, int column) |
| | 0 | 1218 | | { |
| | 0 | 1219 | | return ref GetCellRef(row, column, ref allLayerMaskColumns); |
| | 0 | 1220 | | } |
| | | 1221 | | |
| | | 1222 | | public ref Bounds GetBoundsRef(int row, int column) |
| | 0 | 1223 | | { |
| | 0 | 1224 | | return ref GetCellRef(row, column, ref allBoundsColumns); |
| | 0 | 1225 | | } |
| | | 1226 | | |
| | | 1227 | | public ref BoundsInt GetBoundsIntRef(int row, int column) |
| | 0 | 1228 | | { |
| | 0 | 1229 | | return ref GetCellRef(row, column, ref allBoundsIntColumns); |
| | 0 | 1230 | | } |
| | | 1231 | | |
| | | 1232 | | public ref Hash128 GetHash128Ref(int row, int column) |
| | 0 | 1233 | | { |
| | 0 | 1234 | | return ref GetCellRef(row, column, ref allHash128Columns); |
| | 0 | 1235 | | } |
| | | 1236 | | |
| | | 1237 | | public ref Gradient GetGradientRef(int row, int column) |
| | 0 | 1238 | | { |
| | 0 | 1239 | | return ref GetCellRef(row, column, ref allGradientColumns); |
| | 0 | 1240 | | } |
| | | 1241 | | |
| | | 1242 | | public ref AnimationCurve GetAnimationCurveRef(int row, int column) |
| | 0 | 1243 | | { |
| | 0 | 1244 | | return ref GetCellRef(row, column, ref allAnimationCurveColumns); |
| | 0 | 1245 | | } |
| | | 1246 | | |
| | | 1247 | | public ref UnityEngine.Object GetObjectRef(int row, int column) |
| | 0 | 1248 | | { |
| | 0 | 1249 | | return ref GetCellRef(row, column, ref allObjectRefColumns); |
| | 0 | 1250 | | } |
| | | 1251 | | |
| | | 1252 | | // Get Column |
| | | 1253 | | |
| | | 1254 | | public string[] GetStringColumn(int column) |
| | 0 | 1255 | | { |
| | 0 | 1256 | | return GetColumn(column, ref allStringColumns); |
| | 0 | 1257 | | } |
| | | 1258 | | |
| | | 1259 | | public bool[] GetBoolColumn(int column) |
| | 0 | 1260 | | { |
| | 0 | 1261 | | return GetColumn(column, ref allBoolColumns); |
| | 0 | 1262 | | } |
| | | 1263 | | |
| | | 1264 | | public char[] GetCharColumn(int column) |
| | 0 | 1265 | | { |
| | 0 | 1266 | | return GetColumn(column, ref allCharColumns); |
| | 0 | 1267 | | } |
| | | 1268 | | |
| | | 1269 | | public sbyte[] GetSbyteColumn(int column) |
| | 0 | 1270 | | { |
| | 0 | 1271 | | return GetColumn(column, ref allSbyteColumns); |
| | 0 | 1272 | | } |
| | | 1273 | | |
| | | 1274 | | public byte[] GetByteColumn(int column) |
| | 0 | 1275 | | { |
| | 0 | 1276 | | return GetColumn(column, ref allByteColumns); |
| | 0 | 1277 | | } |
| | | 1278 | | |
| | | 1279 | | public short[] GetShortColumn(int column) |
| | 0 | 1280 | | { |
| | 0 | 1281 | | return GetColumn(column, ref allShortColumns); |
| | 0 | 1282 | | } |
| | | 1283 | | |
| | | 1284 | | public ushort[] GetUshortColumn(int column) |
| | 0 | 1285 | | { |
| | 0 | 1286 | | return GetColumn(column, ref allUshortColumns); |
| | 0 | 1287 | | } |
| | | 1288 | | |
| | | 1289 | | public int[] GetIntColumn(int column) |
| | 0 | 1290 | | { |
| | 0 | 1291 | | return GetColumn(column, ref allIntColumns); |
| | 0 | 1292 | | } |
| | | 1293 | | |
| | | 1294 | | public uint[] GetUintColumn(int column) |
| | 0 | 1295 | | { |
| | 0 | 1296 | | return GetColumn(column, ref allUintColumns); |
| | 0 | 1297 | | } |
| | | 1298 | | |
| | | 1299 | | public long[] GetLongColumn(int column) |
| | 0 | 1300 | | { |
| | 0 | 1301 | | return GetColumn(column, ref allLongColumns); |
| | 0 | 1302 | | } |
| | | 1303 | | |
| | | 1304 | | public ulong[] GetUlongColumn(int column) |
| | 0 | 1305 | | { |
| | 0 | 1306 | | return GetColumn(column, ref allUlongColumns); |
| | 0 | 1307 | | } |
| | | 1308 | | |
| | | 1309 | | public float[] GetFloatColumn(int column) |
| | 0 | 1310 | | { |
| | 0 | 1311 | | return GetColumn(column, ref allFloatColumns); |
| | 0 | 1312 | | } |
| | | 1313 | | |
| | | 1314 | | public double[] GetDoubleColumn(int column) |
| | 0 | 1315 | | { |
| | 0 | 1316 | | return GetColumn(column, ref allDoubleColumns); |
| | 0 | 1317 | | } |
| | | 1318 | | |
| | | 1319 | | public Vector2[] GetVector2Column(int column) |
| | 0 | 1320 | | { |
| | 0 | 1321 | | return GetColumn(column, ref allVector2Columns); |
| | 0 | 1322 | | } |
| | | 1323 | | |
| | | 1324 | | public Vector3[] GetVector3Column(int column) |
| | 0 | 1325 | | { |
| | 0 | 1326 | | return GetColumn(column, ref allVector3Columns); |
| | 0 | 1327 | | } |
| | | 1328 | | |
| | | 1329 | | public Vector4[] GetVector4Column(int column) |
| | 0 | 1330 | | { |
| | 0 | 1331 | | return GetColumn(column, ref allVector4Columns); |
| | 0 | 1332 | | } |
| | | 1333 | | |
| | | 1334 | | public Vector2Int[] GetVector2IntColumn(int column) |
| | 0 | 1335 | | { |
| | 0 | 1336 | | return GetColumn(column, ref allVector2IntColumns); |
| | 0 | 1337 | | } |
| | | 1338 | | |
| | | 1339 | | public Vector3Int[] GetVector3IntColumn(int column) |
| | 0 | 1340 | | { |
| | 0 | 1341 | | return GetColumn(column, ref allVector3IntColumns); |
| | 0 | 1342 | | } |
| | | 1343 | | |
| | | 1344 | | public Quaternion[] GetQuaternionColumn(int column) |
| | 0 | 1345 | | { |
| | 0 | 1346 | | return GetColumn(column, ref allQuaternionColumns); |
| | 0 | 1347 | | } |
| | | 1348 | | |
| | | 1349 | | public Rect[] GetRectColumn(int column) |
| | 0 | 1350 | | { |
| | 0 | 1351 | | return GetColumn(column, ref allRectColumns); |
| | 0 | 1352 | | } |
| | | 1353 | | |
| | | 1354 | | public RectInt[] GetRectIntColumn(int column) |
| | 0 | 1355 | | { |
| | 0 | 1356 | | return GetColumn(column, ref allRectIntColumns); |
| | 0 | 1357 | | } |
| | | 1358 | | |
| | | 1359 | | public Color[] GetColorColumn(int column) |
| | 0 | 1360 | | { |
| | 0 | 1361 | | return GetColumn(column, ref allColorColumns); |
| | 0 | 1362 | | } |
| | | 1363 | | |
| | | 1364 | | public LayerMask[] GetLayerMaskColumn(int column) |
| | 0 | 1365 | | { |
| | 0 | 1366 | | return GetColumn(column, ref allLayerMaskColumns); |
| | 0 | 1367 | | } |
| | | 1368 | | |
| | | 1369 | | public Bounds[] GetBoundsColumn(int column) |
| | 0 | 1370 | | { |
| | 0 | 1371 | | return GetColumn(column, ref allBoundsColumns); |
| | 0 | 1372 | | } |
| | | 1373 | | |
| | | 1374 | | public BoundsInt[] GetBoundsIntColumn(int column) |
| | 0 | 1375 | | { |
| | 0 | 1376 | | return GetColumn(column, ref allBoundsIntColumns); |
| | 0 | 1377 | | } |
| | | 1378 | | |
| | | 1379 | | public Hash128[] GetHash128Column(int column) |
| | 0 | 1380 | | { |
| | 0 | 1381 | | return GetColumn(column, ref allHash128Columns); |
| | 0 | 1382 | | } |
| | | 1383 | | |
| | | 1384 | | public Gradient[] GetGradientColumn(int column) |
| | 0 | 1385 | | { |
| | 0 | 1386 | | return GetColumn(column, ref allGradientColumns); |
| | 0 | 1387 | | } |
| | | 1388 | | |
| | | 1389 | | public AnimationCurve[] GetAnimationCurveColumn(int column) |
| | 0 | 1390 | | { |
| | 0 | 1391 | | return GetColumn(column, ref allAnimationCurveColumns); |
| | 0 | 1392 | | } |
| | | 1393 | | |
| | | 1394 | | public UnityEngine.Object[] GetObjectColumn(int column) |
| | 0 | 1395 | | { |
| | 0 | 1396 | | return GetColumn(column, ref allObjectRefColumns); |
| | 0 | 1397 | | } |
| | | 1398 | | |
| | | 1399 | | // SetOrder |
| | | 1400 | | |
| | | 1401 | | public void SetColumnOrder(int columnID, int newSortOrder) |
| | 0 | 1402 | | { |
| | 0 | 1403 | | AssertColumnIDValid(columnID); |
| | 0 | 1404 | | AssertColumnSortOrderValid(newSortOrder); |
| | 0 | 1405 | | int oldSortOrder = columnIDToSortOrderMap[columnID]; |
| | 0 | 1406 | | int iterDirection = newSortOrder > oldSortOrder ? 1 : -1; |
| | 0 | 1407 | | for (int i = oldSortOrder; i != newSortOrder; i += iterDirection) |
| | 0 | 1408 | | { |
| | 0 | 1409 | | int columnIDAt = sortedOrderToColumnIDMap[i + iterDirection]; |
| | 0 | 1410 | | columnIDToSortOrderMap[columnIDAt] = i; |
| | 0 | 1411 | | sortedOrderToColumnIDMap[i] = sortedOrderToColumnIDMap[i + iterDirection]; |
| | 0 | 1412 | | } |
| | | 1413 | | |
| | 0 | 1414 | | sortedOrderToColumnIDMap[newSortOrder] = columnID; |
| | 0 | 1415 | | columnIDToSortOrderMap[columnID] = newSortOrder; |
| | 0 | 1416 | | } |
| | | 1417 | | |
| | | 1418 | | public void SetAllColumnOrders(int[] sortedColumnIDs) |
| | 0 | 1419 | | { |
| | 0 | 1420 | | AssertSortedColumnsArgValid(sortedColumnIDs); |
| | 0 | 1421 | | for (int i = 0; i < sortedOrderToColumnIDMap.Length; i++) |
| | 0 | 1422 | | { |
| | 0 | 1423 | | int columnID = sortedColumnIDs[i]; |
| | 0 | 1424 | | sortedOrderToColumnIDMap[i] = columnID; |
| | 0 | 1425 | | columnIDToSortOrderMap[columnID] = i; |
| | 0 | 1426 | | } |
| | 0 | 1427 | | } |
| | | 1428 | | |
| | | 1429 | | public void SetRowOrder(int rowID, int newSortOrder) |
| | 0 | 1430 | | { |
| | 0 | 1431 | | AssertRowIDValid(rowID); |
| | 0 | 1432 | | AssertRowSortOrderValid(newSortOrder); |
| | | 1433 | | |
| | 0 | 1434 | | int oldSortOrder = rowIDToDenseIndexMap[rowID]; |
| | 0 | 1435 | | int iterDirection = newSortOrder > oldSortOrder ? 1 : -1; |
| | | 1436 | | |
| | 0 | 1437 | | for (int i = oldSortOrder; i != newSortOrder; i += iterDirection) |
| | 0 | 1438 | | { |
| | 0 | 1439 | | int rowIDAt = rowDenseIndexToIDMap[i + iterDirection]; |
| | 0 | 1440 | | rowIDToDenseIndexMap[rowIDAt] = i; |
| | 0 | 1441 | | rowDenseIndexToIDMap[i] = rowDenseIndexToIDMap[i + iterDirection]; |
| | 0 | 1442 | | } |
| | | 1443 | | |
| | 0 | 1444 | | SetRowOrderForColumns(allStringColumns, oldSortOrder, newSortOrder); |
| | 0 | 1445 | | SetRowOrderForColumns(allBoolColumns, oldSortOrder, newSortOrder); |
| | 0 | 1446 | | SetRowOrderForColumns(allCharColumns, oldSortOrder, newSortOrder); |
| | 0 | 1447 | | SetRowOrderForColumns(allSbyteColumns, oldSortOrder, newSortOrder); |
| | 0 | 1448 | | SetRowOrderForColumns(allByteColumns, oldSortOrder, newSortOrder); |
| | 0 | 1449 | | SetRowOrderForColumns(allShortColumns, oldSortOrder, newSortOrder); |
| | 0 | 1450 | | SetRowOrderForColumns(allUshortColumns, oldSortOrder, newSortOrder); |
| | 0 | 1451 | | SetRowOrderForColumns(allIntColumns, oldSortOrder, newSortOrder); |
| | 0 | 1452 | | SetRowOrderForColumns(allUintColumns, oldSortOrder, newSortOrder); |
| | 0 | 1453 | | SetRowOrderForColumns(allLongColumns, oldSortOrder, newSortOrder); |
| | 0 | 1454 | | SetRowOrderForColumns(allUlongColumns, oldSortOrder, newSortOrder); |
| | 0 | 1455 | | SetRowOrderForColumns(allFloatColumns, oldSortOrder, newSortOrder); |
| | 0 | 1456 | | SetRowOrderForColumns(allDoubleColumns, oldSortOrder, newSortOrder); |
| | 0 | 1457 | | SetRowOrderForColumns(allVector2Columns, oldSortOrder, newSortOrder); |
| | 0 | 1458 | | SetRowOrderForColumns(allVector3Columns, oldSortOrder, newSortOrder); |
| | 0 | 1459 | | SetRowOrderForColumns(allVector4Columns, oldSortOrder, newSortOrder); |
| | 0 | 1460 | | SetRowOrderForColumns(allVector2IntColumns, oldSortOrder, newSortOrder); |
| | 0 | 1461 | | SetRowOrderForColumns(allVector3IntColumns, oldSortOrder, newSortOrder); |
| | 0 | 1462 | | SetRowOrderForColumns(allQuaternionColumns, oldSortOrder, newSortOrder); |
| | 0 | 1463 | | SetRowOrderForColumns(allRectColumns, oldSortOrder, newSortOrder); |
| | 0 | 1464 | | SetRowOrderForColumns(allRectIntColumns, oldSortOrder, newSortOrder); |
| | 0 | 1465 | | SetRowOrderForColumns(allColorColumns, oldSortOrder, newSortOrder); |
| | 0 | 1466 | | SetRowOrderForColumns(allLayerMaskColumns, oldSortOrder, newSortOrder); |
| | 0 | 1467 | | SetRowOrderForColumns(allBoundsColumns, oldSortOrder, newSortOrder); |
| | 0 | 1468 | | SetRowOrderForColumns(allBoundsIntColumns, oldSortOrder, newSortOrder); |
| | 0 | 1469 | | SetRowOrderForColumns(allHash128Columns, oldSortOrder, newSortOrder); |
| | 0 | 1470 | | SetRowOrderForColumns(allGradientColumns, oldSortOrder, newSortOrder); |
| | 0 | 1471 | | SetRowOrderForColumns(allAnimationCurveColumns, oldSortOrder, newSortOrder); |
| | 0 | 1472 | | SetRowOrderForColumns(allObjectRefColumns, oldSortOrder, newSortOrder); |
| | 0 | 1473 | | } |
| | | 1474 | | |
| | | 1475 | | public void SetAllRowOrders(int[] sortedRowIDs) |
| | 0 | 1476 | | { |
| | 0 | 1477 | | AssertSorteRowsArgValid(sortedRowIDs); |
| | | 1478 | | |
| | 0 | 1479 | | ReSortRows(allStringColumns, sortedRowIDs); |
| | 0 | 1480 | | ReSortRows(allBoolColumns, sortedRowIDs); |
| | 0 | 1481 | | ReSortRows(allCharColumns, sortedRowIDs); |
| | 0 | 1482 | | ReSortRows(allSbyteColumns, sortedRowIDs); |
| | 0 | 1483 | | ReSortRows(allByteColumns, sortedRowIDs); |
| | 0 | 1484 | | ReSortRows(allShortColumns, sortedRowIDs); |
| | 0 | 1485 | | ReSortRows(allUshortColumns, sortedRowIDs); |
| | 0 | 1486 | | ReSortRows(allIntColumns, sortedRowIDs); |
| | 0 | 1487 | | ReSortRows(allUintColumns, sortedRowIDs); |
| | 0 | 1488 | | ReSortRows(allLongColumns, sortedRowIDs); |
| | 0 | 1489 | | ReSortRows(allUlongColumns, sortedRowIDs); |
| | 0 | 1490 | | ReSortRows(allFloatColumns, sortedRowIDs); |
| | 0 | 1491 | | ReSortRows(allDoubleColumns, sortedRowIDs); |
| | 0 | 1492 | | ReSortRows(allVector2Columns, sortedRowIDs); |
| | 0 | 1493 | | ReSortRows(allVector3Columns, sortedRowIDs); |
| | 0 | 1494 | | ReSortRows(allVector4Columns, sortedRowIDs); |
| | 0 | 1495 | | ReSortRows(allVector2IntColumns, sortedRowIDs); |
| | 0 | 1496 | | ReSortRows(allVector3IntColumns, sortedRowIDs); |
| | 0 | 1497 | | ReSortRows(allQuaternionColumns, sortedRowIDs); |
| | 0 | 1498 | | ReSortRows(allRectColumns, sortedRowIDs); |
| | 0 | 1499 | | ReSortRows(allRectIntColumns, sortedRowIDs); |
| | 0 | 1500 | | ReSortRows(allColorColumns, sortedRowIDs); |
| | 0 | 1501 | | ReSortRows(allLayerMaskColumns, sortedRowIDs); |
| | 0 | 1502 | | ReSortRows(allBoundsColumns, sortedRowIDs); |
| | 0 | 1503 | | ReSortRows(allBoundsIntColumns, sortedRowIDs); |
| | 0 | 1504 | | ReSortRows(allHash128Columns, sortedRowIDs); |
| | 0 | 1505 | | ReSortRows(allGradientColumns, sortedRowIDs); |
| | 0 | 1506 | | ReSortRows(allAnimationCurveColumns, sortedRowIDs); |
| | 0 | 1507 | | ReSortRows(allObjectRefColumns, sortedRowIDs); |
| | | 1508 | | |
| | 0 | 1509 | | for (int i = 0; i < sortedRowIDs.Length; i++) |
| | 0 | 1510 | | { |
| | 0 | 1511 | | int rowID = sortedRowIDs[i]; |
| | 0 | 1512 | | rowDenseIndexToIDMap[i] = rowID; |
| | 0 | 1513 | | rowIDToDenseIndexMap[rowID] = i; |
| | 0 | 1514 | | } |
| | 0 | 1515 | | } |
| | | 1516 | | |
| | | 1517 | | internal void ReSortRows<T>(ArrayHolder<T>[] columns, int[] sortedRowIDs) |
| | 0 | 1518 | | { |
| | 0 | 1519 | | for (int i = 0; i < columns.Length; i++) |
| | 0 | 1520 | | { |
| | 0 | 1521 | | T[] column = columns[i].TArray; |
| | | 1522 | | |
| | 0 | 1523 | | for (int j = 0; j < sortedRowIDs.Length; j++) |
| | 0 | 1524 | | { |
| | 0 | 1525 | | T rowValueAt = column[j]; |
| | 0 | 1526 | | int rowID = sortedRowIDs[j]; |
| | 0 | 1527 | | int oldRowIndex = rowIDToDenseIndexMap[rowID]; |
| | | 1528 | | |
| | 0 | 1529 | | column[j] = column[oldRowIndex]; |
| | 0 | 1530 | | column[oldRowIndex] = rowValueAt; |
| | 0 | 1531 | | } |
| | 0 | 1532 | | } |
| | 0 | 1533 | | } |
| | | 1534 | | |
| | | 1535 | | // Internal |
| | | 1536 | | |
| | | 1537 | | internal int AddColumnInternal<T>(string columnName, ref ArrayHolder<T>[] allColumnsOfType, Serializable.Seriali |
| | 0 | 1538 | | { |
| | 0 | 1539 | | if (insertAtColumnID >= 0) |
| | 0 | 1540 | | { |
| | 0 | 1541 | | AssertColumnIDValid(insertAtColumnID); |
| | 0 | 1542 | | } |
| | 0 | 1543 | | int columnCount = allColumnsOfType?.Length ?? 0; |
| | 0 | 1544 | | Array.Resize(ref allColumnsOfType, columnCount + 1); |
| | 0 | 1545 | | allColumnsOfType[columnCount].TArray = new T[rowCount]; |
| | | 1546 | | |
| | 0 | 1547 | | int columnID = columnEntriesFreeListHead; |
| | 0 | 1548 | | string[] columnNamesForType = allColumnNames[(int)typeIndex].TArray; |
| | 0 | 1549 | | int columnNamesCount = columnNamesForType?.Length ?? 0; |
| | 0 | 1550 | | Array.Resize(ref columnNamesForType, columnNamesCount + 1); |
| | 0 | 1551 | | columnNamesForType[columnNamesCount] = columnName == null ? columnID.ToString() : columnName; |
| | 0 | 1552 | | allColumnNames[(int)typeIndex].TArray = columnNamesForType; |
| | | 1553 | | |
| | | 1554 | | |
| | 0 | 1555 | | int columnIDToDenseIndexMapLength = columnIDToDenseIndexMap?.Length ?? 0; |
| | 0 | 1556 | | if (columnID >= columnIDToDenseIndexMapLength) |
| | 0 | 1557 | | { |
| | 0 | 1558 | | int newSize = columnIDToDenseIndexMapLength * 2; |
| | 0 | 1559 | | newSize = newSize == 0 ? 1 : newSize; |
| | 0 | 1560 | | Array.Resize(ref columnIDToDenseIndexMap, newSize); |
| | 0 | 1561 | | for (int i = columnIDToDenseIndexMapLength; i < newSize; i++) |
| | 0 | 1562 | | { |
| | 0 | 1563 | | ref ColumnEntry entry = ref columnIDToDenseIndexMap[i]; |
| | 0 | 1564 | | entry.columnDenseIndex = i + 1; |
| | 0 | 1565 | | entry.ColumnType = Serializable.SerializableTypes.Invalid; |
| | 0 | 1566 | | } |
| | | 1567 | | |
| | 0 | 1568 | | Array.Resize(ref columnIDToSortOrderMap, newSize); |
| | 0 | 1569 | | for (int i = columnIDToDenseIndexMapLength; i < newSize; i++) |
| | 0 | 1570 | | { |
| | 0 | 1571 | | columnIDToSortOrderMap[i] = -1; |
| | 0 | 1572 | | } |
| | 0 | 1573 | | } |
| | | 1574 | | |
| | 0 | 1575 | | columnEntriesFreeListHead = columnIDToDenseIndexMap[columnID].columnDenseIndex; |
| | | 1576 | | |
| | 0 | 1577 | | ref int[] denseIndexToIDMap = ref columnDenseIndexToIDMap[(int)typeIndex].TArray; |
| | 0 | 1578 | | int denseIndexToIDMapLength = denseIndexToIDMap?.Length ?? 0; |
| | 0 | 1579 | | Array.Resize(ref denseIndexToIDMap, denseIndexToIDMapLength + 1); |
| | 0 | 1580 | | denseIndexToIDMap[denseIndexToIDMapLength] = columnID; |
| | | 1581 | | |
| | 0 | 1582 | | ref ColumnEntry newEntry = ref columnIDToDenseIndexMap[columnID]; |
| | 0 | 1583 | | newEntry.columnDenseIndex = denseIndexToIDMapLength; |
| | 0 | 1584 | | newEntry.ColumnType = typeIndex; |
| | | 1585 | | |
| | 0 | 1586 | | int insertAtSortedIndex = insertAtColumnID < 0 ? combinedColumnCount : columnIDToSortOrderMap[insertAtColumn |
| | 0 | 1587 | | Array.Resize(ref sortedOrderToColumnIDMap, combinedColumnCount + 1); |
| | 0 | 1588 | | for (int i = combinedColumnCount; i > insertAtSortedIndex; i--) |
| | 0 | 1589 | | { |
| | 0 | 1590 | | int currentColumnID = sortedOrderToColumnIDMap[i - 1]; |
| | 0 | 1591 | | sortedOrderToColumnIDMap[i] = currentColumnID; |
| | 0 | 1592 | | columnIDToSortOrderMap[currentColumnID] = i; |
| | 0 | 1593 | | } |
| | | 1594 | | |
| | | 1595 | | |
| | 0 | 1596 | | columnIDToSortOrderMap[columnID] = insertAtSortedIndex; |
| | 0 | 1597 | | sortedOrderToColumnIDMap[insertAtSortedIndex] = columnID; |
| | | 1598 | | |
| | 0 | 1599 | | ++combinedColumnCount; |
| | 0 | 1600 | | dataVersion++; |
| | | 1601 | | |
| | 0 | 1602 | | return columnID; |
| | 0 | 1603 | | } |
| | | 1604 | | |
| | | 1605 | | internal void RemoveColumnInternal<T>(ref ArrayHolder<T>[] allColumnsOfType, Serializable.SerializableTypes type |
| | 0 | 1606 | | { |
| | 0 | 1607 | | AssertColumnIDValid(columnID); |
| | 0 | 1608 | | int columnLocation = columnIDToDenseIndexMap[columnID].columnDenseIndex; |
| | | 1609 | | |
| | 0 | 1610 | | int lastIndex = allColumnsOfType.Length - 1; |
| | 0 | 1611 | | allColumnsOfType[columnLocation] = allColumnsOfType[lastIndex]; |
| | 0 | 1612 | | Array.Resize(ref allColumnsOfType, lastIndex); |
| | | 1613 | | |
| | 0 | 1614 | | ref string[] columnNamesOfType = ref allColumnNames[(int)typeIndex].TArray; |
| | 0 | 1615 | | columnNamesOfType[columnLocation] = columnNamesOfType[lastIndex]; |
| | 0 | 1616 | | Array.Resize(ref columnNamesOfType, lastIndex); |
| | | 1617 | | |
| | 0 | 1618 | | int columnOrder = columnIDToSortOrderMap[columnID]; |
| | | 1619 | | |
| | 0 | 1620 | | ref int[] denseIndicesOfType = ref columnDenseIndexToIDMap[(int)typeIndex].TArray; |
| | 0 | 1621 | | int sparseIndexToSwap = denseIndicesOfType[lastIndex]; |
| | | 1622 | | |
| | 0 | 1623 | | ref ColumnEntry sparseIndexToFree = ref columnIDToDenseIndexMap[columnID]; |
| | 0 | 1624 | | sparseIndexToFree.ColumnType = Serializable.SerializableTypes.Invalid; |
| | 0 | 1625 | | sparseIndexToFree.columnDenseIndex = columnEntriesFreeListHead; |
| | 0 | 1626 | | columnEntriesFreeListHead = columnID; |
| | | 1627 | | |
| | 0 | 1628 | | columnIDToDenseIndexMap[sparseIndexToSwap].columnDenseIndex = columnLocation; |
| | 0 | 1629 | | denseIndicesOfType[columnLocation] = sparseIndexToSwap; |
| | 0 | 1630 | | Array.Resize(ref denseIndicesOfType, lastIndex); |
| | | 1631 | | |
| | 0 | 1632 | | for (int i = columnOrder + 1; i < combinedColumnCount; i++) |
| | 0 | 1633 | | { |
| | 0 | 1634 | | int currentColumnID = sortedOrderToColumnIDMap[i]; |
| | 0 | 1635 | | sortedOrderToColumnIDMap[i - 1] = currentColumnID; |
| | 0 | 1636 | | columnIDToSortOrderMap[currentColumnID] = i - 1; |
| | 0 | 1637 | | } |
| | | 1638 | | |
| | 0 | 1639 | | Array.Resize(ref sortedOrderToColumnIDMap, combinedColumnCount - 1); |
| | | 1640 | | |
| | 0 | 1641 | | --combinedColumnCount; |
| | 0 | 1642 | | dataVersion++; |
| | 0 | 1643 | | } |
| | | 1644 | | |
| | | 1645 | | internal void InsertRowsOfTypeInternal<T>(ref ArrayHolder<T>[] allColumnsOfType, int insertAt, int numberOfNewRo |
| | 0 | 1646 | | { |
| | 0 | 1647 | | int columnCount = allColumnsOfType?.Length ?? 0; |
| | 0 | 1648 | | for (int i = 0; i < columnCount; i++) |
| | 0 | 1649 | | { |
| | 0 | 1650 | | ref T[] rows = ref allColumnsOfType[i].TArray; |
| | 0 | 1651 | | int newRowCount = rowCount + numberOfNewRows; |
| | 0 | 1652 | | Array.Resize(ref rows, newRowCount); |
| | 0 | 1653 | | for (int j = newRowCount - 1; j > insertAt + numberOfNewRows - 1; j--) |
| | 0 | 1654 | | { |
| | 0 | 1655 | | rows[j] = rows[j - numberOfNewRows]; |
| | 0 | 1656 | | } |
| | | 1657 | | |
| | 0 | 1658 | | for (int j = 0; j < numberOfNewRows; j++) |
| | 0 | 1659 | | { |
| | 0 | 1660 | | rows[insertAt + j] = default; |
| | 0 | 1661 | | } |
| | 0 | 1662 | | } |
| | 0 | 1663 | | } |
| | | 1664 | | |
| | | 1665 | | internal void DeleteRowsOfTypeInternal<T>(ref ArrayHolder<T>[] allColumnsOfType, int removeAt, int numberOfRowsT |
| | 0 | 1666 | | { |
| | 0 | 1667 | | int columnCount = allColumnsOfType?.Length ?? 0; |
| | | 1668 | | |
| | 0 | 1669 | | for (int i = 0; i < columnCount; i++) |
| | 0 | 1670 | | { |
| | 0 | 1671 | | ref T[] rows = ref allColumnsOfType[i].TArray; |
| | 0 | 1672 | | int newRowCount = rowCount - numberOfRowsToDelete; |
| | | 1673 | | |
| | 0 | 1674 | | for (int j = removeAt + numberOfRowsToDelete; j < rowCount; j++) |
| | 0 | 1675 | | { |
| | 0 | 1676 | | rows[j - numberOfRowsToDelete] = rows[j]; |
| | 0 | 1677 | | } |
| | | 1678 | | |
| | 0 | 1679 | | Array.Resize(ref rows, newRowCount); |
| | 0 | 1680 | | } |
| | 0 | 1681 | | } |
| | | 1682 | | |
| | | 1683 | | internal ref T GetCellRef<T>(int rowID, int columnID, ref ArrayHolder<T>[] allColumnsOfType) |
| | 0 | 1684 | | { |
| | 0 | 1685 | | AssertColumnIDValid(columnID); |
| | 0 | 1686 | | AssertRowIDValid(rowID); |
| | 0 | 1687 | | int column = columnIDToDenseIndexMap[columnID].columnDenseIndex; |
| | 0 | 1688 | | int row = rowIDToDenseIndexMap[rowID]; |
| | 0 | 1689 | | return ref allColumnsOfType[column][row]; |
| | 0 | 1690 | | } |
| | | 1691 | | |
| | | 1692 | | internal T GetCell<T>(int rowID, int columnID, ref ArrayHolder<T>[] allColumnsOfType) |
| | 0 | 1693 | | { |
| | 0 | 1694 | | AssertColumnIDValid(columnID); |
| | 0 | 1695 | | AssertRowIDValid(rowID); |
| | 0 | 1696 | | int column = columnIDToDenseIndexMap[columnID].columnDenseIndex; |
| | 0 | 1697 | | int row = rowIDToDenseIndexMap[rowID]; |
| | 0 | 1698 | | return allColumnsOfType[column][row]; |
| | 0 | 1699 | | } |
| | | 1700 | | |
| | | 1701 | | internal ulong SetCell<T>(int rowID, int columnID, ref ArrayHolder<T>[] allColumnsOfType, T value) |
| | 0 | 1702 | | { |
| | 0 | 1703 | | AssertColumnIDValid(columnID); |
| | 0 | 1704 | | AssertRowIDValid(rowID); |
| | 0 | 1705 | | int column = columnIDToDenseIndexMap[columnID].columnDenseIndex; |
| | 0 | 1706 | | int row = rowIDToDenseIndexMap[rowID]; |
| | 0 | 1707 | | allColumnsOfType[column][row] = value; |
| | 0 | 1708 | | dataVersion++; |
| | 0 | 1709 | | return dataVersion; |
| | 0 | 1710 | | } |
| | | 1711 | | |
| | | 1712 | | internal T[] GetColumn<T>(int columnID, ref ArrayHolder<T>[] allColumnsOfType) |
| | 0 | 1713 | | { |
| | 0 | 1714 | | AssertColumnIDValid(columnID); |
| | 0 | 1715 | | int column = columnIDToDenseIndexMap[columnID].columnDenseIndex; |
| | 0 | 1716 | | return allColumnsOfType[column].TArray; |
| | 0 | 1717 | | } |
| | | 1718 | | |
| | | 1719 | | internal void SetRowOrderForColumns<T>(ArrayHolder<T>[] columns, int oldSortOrder, int newSortOrder) |
| | 0 | 1720 | | { |
| | 0 | 1721 | | int iterDirection = newSortOrder > oldSortOrder ? 1 : -1; |
| | 0 | 1722 | | for (int i = 0; i < columns.Length; i++) |
| | 0 | 1723 | | { |
| | 0 | 1724 | | T[] column = columns[i].TArray; |
| | | 1725 | | |
| | 0 | 1726 | | for (int j = oldSortOrder; j != newSortOrder; j += iterDirection) |
| | 0 | 1727 | | { |
| | 0 | 1728 | | column[j] = column[j + iterDirection]; |
| | 0 | 1729 | | } |
| | 0 | 1730 | | } |
| | 0 | 1731 | | } |
| | | 1732 | | |
| | | 1733 | | internal void AssertSortedColumnsArgValid(int[] sortedColumnIDs) |
| | 0 | 1734 | | { |
| | 0 | 1735 | | if (sortedColumnIDs == null) |
| | 0 | 1736 | | { |
| | 0 | 1737 | | throw new ArgumentException("sortedColumnIDs array cannot be null."); |
| | | 1738 | | } |
| | | 1739 | | |
| | 0 | 1740 | | if (sortedColumnIDs.Length != sortedOrderToColumnIDMap.Length) |
| | 0 | 1741 | | { |
| | 0 | 1742 | | throw new ArgumentException("sortedColumnIDs array must be the same length as GetColumnCount."); |
| | | 1743 | | } |
| | | 1744 | | |
| | 0 | 1745 | | for (int i = 0; i < sortedColumnIDs.Length; i++) |
| | 0 | 1746 | | { |
| | 0 | 1747 | | AssertColumnIDValid(sortedColumnIDs[i]); |
| | 0 | 1748 | | } |
| | 0 | 1749 | | } |
| | | 1750 | | |
| | | 1751 | | internal void AssertColumnSortOrderValid(int sortedOrder) |
| | 0 | 1752 | | { |
| | 0 | 1753 | | if (sortedOrder >= combinedColumnCount || sortedOrder < 0) |
| | 0 | 1754 | | { |
| | 0 | 1755 | | throw new ArgumentException("Invalid column sort order argument: " + sortedOrder); |
| | | 1756 | | } |
| | 0 | 1757 | | } |
| | | 1758 | | |
| | | 1759 | | internal void AssertRowSortOrderValid(int sortedOrder) |
| | 0 | 1760 | | { |
| | 0 | 1761 | | if (sortedOrder >= rowCount || sortedOrder < 0) |
| | 0 | 1762 | | { |
| | 0 | 1763 | | throw new ArgumentException("Invalid row sort order argument: " + sortedOrder); |
| | | 1764 | | } |
| | 0 | 1765 | | } |
| | | 1766 | | |
| | | 1767 | | internal void AssertSorteRowsArgValid(int[] sortedRowIDs) |
| | 0 | 1768 | | { |
| | 0 | 1769 | | if (sortedRowIDs == null) |
| | 0 | 1770 | | { |
| | 0 | 1771 | | throw new ArgumentException("sortedRowIDs array cannot be null."); |
| | | 1772 | | } |
| | | 1773 | | |
| | 0 | 1774 | | if (sortedRowIDs.Length != rowDenseIndexToIDMap.Length) |
| | 0 | 1775 | | { |
| | 0 | 1776 | | throw new ArgumentException("sortedRowIDs array must be the same length as GetRowCount."); |
| | | 1777 | | } |
| | | 1778 | | |
| | 0 | 1779 | | for (int i = 0; i < sortedRowIDs.Length; i++) |
| | 0 | 1780 | | { |
| | 0 | 1781 | | AssertRowIDValid(sortedRowIDs[i]); |
| | 0 | 1782 | | } |
| | 0 | 1783 | | } |
| | | 1784 | | } |
| | | 1785 | | } |